Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tests/e2e/testRunner.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import launchApp from './utils/launchApp';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHy this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this launch app test is converted into es6 module so I also changed it here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nodeJS only app, you can't use import statements here (or we need to transpile the code)

This caused a regression of breaking all e2e tests:

(node:3308) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/tmp/scratcholkuFS.scratch/test-packageo7zoRO/zip/e2e/testRunner.js:1
import launchApp from './utils/launchApp';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1126:15)
    at Module._compile (node:internal/modules/cjs/loader:1162:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not getting converted to an es6 module

@hannojg hannojg Feb 19, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh wait, I am just seeing that you changed the scripts in package.json to ts-node. Okay, I mean we can do it like this, but this still needs to be addressed on the infra side as well. I will put up a PR


/**
* Multifaceted script, its main function is running the e2e tests.
*
Expand All @@ -20,7 +22,7 @@ const defaultConfig = require('./config');
const Logger = require('./utils/logger');
const execAsync = require('./utils/execAsync');
const killApp = require('./utils/killApp');
const launchApp = require('./utils/launchApp');

const createServerInstance = require('./server');
const installApp = require('./utils/installApp');
const withFailTimeout = require('./utils/withFailTimeout');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable rulesdir/prefer-underscore-method */
const {APP_PACKAGE, ACTIVITY_PATH} = require('../config');
const execAsync = require('./execAsync');
import {ACTIVITY_PATH, MAIN_APP_PACKAGE} from '../config';
import execAsync from './execAsync';

module.exports = function (platform = 'android', packageName = APP_PACKAGE, activityPath = ACTIVITY_PATH, launchArgs = {}) {
const launchApp = (platform = 'android', packageName = MAIN_APP_PACKAGE, activityPath = ACTIVITY_PATH, launchArgs: Record<string, boolean> = {}) => {
if (platform !== 'android') {
throw new Error(`launchApp() missing implementation for platform: ${platform}`);
}
Expand All @@ -13,3 +13,5 @@ module.exports = function (platform = 'android', packageName = APP_PACKAGE, acti
.join(' ');
return execAsync(`adb shell am start -n ${packageName}/${activityPath} ${launchArgsString}`);
};

export default launchApp;