Detox Error: Timeout of 120000ms exceeded. For async tests and hooks - react-native

I'm trying to run some e2e tests in my react-native up I'm using Detox but I keep getting the following error
1) "before all" hook:
Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
child_process.js:644
throw err;
^
Error: Command failed: node_modules/.bin/mocha e2e --opts e2e/mocha.opts
at checkExecSyncError (child_process.js:601:13)
at Object.execSync (child_process.js:641:13)
at runMocha (/Users/Almog/Full-Time-Employment/Construction-Cloud/RnD/CCMobileApp/node_modules/detox/local-cli/detox-test.js:72:6)
at Object.<anonymous> (/Users/Almog/Full-Time-Employment/Construction-Cloud/RnD/CCMobileApp/node_modules/detox/local-cli/detox-test.js:50:5)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)

Try to run it with detox test --loglevel verbose flag it may provide you additional information on what is the issue.

Related

BrowserslistError: Unknown browser query `dead` while running "Sanity Start"

when I try to run "Sanity Start" I get the below error.
C:\Users\Jatan\Shareme\shareme_backend>sanity start
BrowserslistError: Unknown browser query `dead`
at C:/Users/Jatan/Shareme/shareme_backend/node_modules/postcss-cssnext/node_modules/browserslist/index.js:164:11
at Array.reduce (<anonymous>)
at resolve (C:/Users/Jatan/Shareme/shareme_backend/node_modules/postcss-cssnext/node_modules/browserslist/index.js:132:18)
at browserslist (C:/Users/Jatan/Shareme/shareme_backend/node_modules/postcss-cssnext/node_modules/browserslist/index.js:224:16)
at cleanBrowsersList (C:/Users/Jatan/Shareme/shareme_backend/node_modules/postcss-cssnext/node_modules/caniuse-api/dist/utils.js:56:59)
at setBrowserScope (C:/Users/Jatan/Shareme/shareme_backend/node_modules/postcss-cssnext/node_modules/caniuse-api/dist/index.js:26:43)
at Object.<anonymous> (C:/Users/Jatan/Shareme/shareme_backend/node_modules/postcss-cssnext/node_modules/caniuse-api/dist/index.js:88:1)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)

npm --prefix <dependency path> run <lifecycle scripts> (preinstall/install/postinstall/preprepare/prepare/postprepare) fails

I am trying to manually run lifecycle scripts of node_module dependencies for a project with npm --prefix <path> run <lifecycle script> after running npm -w <workspaces> ci --ignore-scripts.
I am attaching a part of log outputs of the scripts I wrote below.
...
Running prepare in node_modules/node-fetch
sh: 1: cross-env: not found
sh: 1: cross-env: not found
Running prepare in node_modules/#graphql-eslint/eslint-plugin/node_modules/cross-fetch
sh: 1: husky: not found
sh: 1: husky: not found
Running prepare in node_modules/sync-fetch
sh: 1: browserify: not found
sh: 1: browserify: not found
Running prepare in node_modules/#iarna/toml
> #iarna/toml#2.2.5 prepare
> npm run setup-burntsushi-toml-suite && npm run setup-iarna-toml-suite
> #iarna/toml#2.2.5 setup-burntsushi-toml-suite
> [ -d test/burntsushi-toml-test ] || (git clone https://github.com/BurntSushi/toml-test test/burntsushi-toml-test; rimraf test/burntsushi-toml-test/.git/hooks/*); cd test/burntsushi-toml-test; git pull
Already up to date.
> #iarna/toml#2.2.5 setup-iarna-toml-suite
> [ -d test/spec-test ] || (git clone https://github.com/iarna/toml-spec-tests -b 0.5.0 test/spec-test; rimraf test/spec-test/.git/hooks/*); cd test/spec-test; git pull
Already up to date.
Running prepare in node_modules/camel-case
Running prepare in node_modules/pascal-case
Running prepare in node_modules/yargs
Running prepare in node_modules/lower-case
Running prepare in node_modules/no-case
Running prepare in node_modules/#graphql-tools/utils/node_modules/camel-case
Running prepare in node_modules/send/node_modules/mime
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'mime-score'
Require stack:
- <path to the project>/node_modules/send/node_modules/mime/src/build.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (<path to the project>/node_modules/send/node_modules/mime/src/build.js:7:19)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'<path to the project>/node_modules/send/node_modules/mime/src/build.js'
]
}
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'mime-score'
Require stack:
- <path to the project>/node_modules/send/node_modules/mime/src/build.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (<path to the project>/node_modules/send/node_modules/mime/src/build.js:7:19)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'<path to the project>/node_modules/send/node_modules/mime/src/build.js'
]
}
...
Running prepare in /node_modules/#storybook/addon-actions
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '<path to the project>/node_modules/scripts/prepare.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '<path to the project>/node_modules/scripts/prepare.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
...
Based on the log, it seems like npm --prefix <path> run <lifecycle script> is often trying to run scripts that does not exist or use commands not installed, and thus fails.
Since some lifecycle scripts removes some codes and tries to rebuild them, I am also failing to build services in my root project.
I was suspecting this might be because
npm ci uses hoisting
dependencies have outdated lifecycle scripts in their package.json's
but after thinking, I don't think neither would be the case and this shouldn't be happening, because npm runs lifecycle scripts after npm ci in the background, and I was able to build services successfully when I used npm -w <workspaces> ci

How can I retry failed end to end tests in Detox using Mocha?

I have a flaky end-to-end test that uses Detox and Mocha.
The Mocha test runner allows for multiple retries. I tried using the recommended Mocha syntax:
// auth.spec.js
describe('App authentication', () => {
this.retries(2);
it('should have a login screen', async () => {
await expect(element(by.id('LoginScreenView'))).toBeVisible();
});
});
However, it appears this is an empty object ({}) and does not have a retries function when running Detox with Mocha as the test runner.
It generates the following error:
node_modules/.bin/mocha __e2e__ --opts __e2e__/config/mocha.opts --
configuration ios.sim.debug --grep :android: --invert --artifacts-location "__e2e__/artifacts/ios.sim.debug.2018-10-17 22-51-12Z"
/<path>/__e2e__/auth.spec.js:10
this.retries(2);
^
TypeError: this.retries is not a function
at Suite.describe (/<path>/__e2e__/auth.spec.js:4:8)
at Object.create (/<path>/node_modules/mocha/lib/interfaces/common.js:112:19)
at context.describe.context.context (/<path>/node_modules/mocha/lib/interfaces/bdd.js:40:27)
at Object.<anonymous> (/<path>/__e2e__/auth.spec.js:3:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at /<path>/node_modules/mocha/lib/mocha.js:250:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/<path>/node_modules/mocha/lib/mocha.js:247:14)
at Mocha.run (/<path>/node_modules/mocha/lib/mocha.js:576:10)
at Object.<anonymous> (/<path>/node_modules/mocha/bin/_mocha:637:18)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3
child_process.js:644
throw err;
^
Is there a way to automatically retry failed tests in Detox?
this in mocha can't work with arrow function, so must change it into ordinary one
// auth.spec.js
describe('App authentication', function () { // change it
this.retries(2);
It is not recommended best practice to use in Mocha
Ref:
https://mochajs.org/#arrow-functions
Hope it helps

Yarn run build SyntaxError

runing Electron Build result in a SyntaxError: Unexpected token function
$ build
...\node_modules\read-config-file\out\main.js:72
async function readConfig(configFile) {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
Found a fix
This issue is realated to
https://github.com/electron-userland/electron-builder/issues/2986
Looks like the issue is not present in version or electron builder before 20.8.1
If you are using node version 7.x or lower, update your node installation.
Async is not supported until node version 8.

gulp protractor - Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:48107

vegan#vegan:~/xxx-yyy/gateway$ gulp protractor qa
[10:52:58] Using gulpfile ~/xxx-yyy/gateway/gulpfile.js
[10:52:58] Starting 'protractor'...
[10:52:58] Starting 'qa'...
[10:52:58] Finished 'qa' after 76 μs
Using ChromeDriver directly...
[launcher] Running 1 instances of WebDriver
/home/vegan/xxx-yyy/gateway/node_modules/selenium-webdriver/http/index.js:174
callback(new Error(message));
^
Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:48107
at ClientRequest.<anonymous> (/home/vegan/xxx-yyy/gateway/node_modules/selenium-webdriver/http/index.js:174:16)
at emitOne (events.js:90:13)
at ClientRequest.emit (events.js:182:7)
at Socket.socketErrorListener (_http_client.js:306:9)
at emitOne (events.js:90:13)
at Socket.emit (events.js:182:7)
at emitErrorNT (net.js:1265:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/home/vegan/xxx-yyy/gateway/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
at Function.webdriver.WebDriver.createSession (/home/vegan/xxx-yyy/gateway/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
at new Driver (/home/vegan/xxx-yyy/gateway/node_modules/selenium-webdriver/chrome.js:810:36)
at [object Object].DirectDriverProvider.getNewDriver (/home/vegan/xxx-yyy/gateway/node_modules/gulp-protractor/node_modules/protractor/lib/driverProviders/direct.js:68:16)
at [object Object].Runner.createBrowser (/home/vegan/xxx-yyy/gateway/node_modules/gulp-protractor/node_modules/protractor/lib/runner.js:186:37)
at /home/vegan/xxx-yyy/gateway/node_modules/gulp-protractor/node_modules/protractor/lib/runner.js:276:21
at _fulfilled (/home/vegan/xxx-yyy/gateway/node_modules/gulp-protractor/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/home/vegan/xxx-yyy/gateway/node_modules/gulp-protractor/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/home/vegan/xxx-yyy/gateway/node_modules/gulp-protractor/node_modules/q/q.js:759:13)
at /home/vegan/xxx-yyy/gateway/node_modules/gulp-protractor/node_modules/q/q.js:525:49
[launcher] Process exited with error code 1
[10:52:58] gulp-notify: [JHipster Gulp Build] Error: protractor exited with code 1
[10:52:58] Finished 'protractor' after 641 ms
[10:52:58] E2E Tests failed
i get this error when i run gulp protractor qa
it says
at new Driver (/home/vegan/xxx-yyy/gateway/node_modules/selenium-webdriver/chrome.js:810:36)
it opens a chrome browser when i run but it stays at there browser.
the path is
/home/vegan/xxx/gateway/node_modules/selenium-webdriver
i do
webdriver-manager update but it doesnot work
Why does this happen? I cant find a way for months.
vegan#vegan:~/xxx-yyyy/gateway$ webdriver-manager update
/usr/lib/node_modules/protractor/node_modules/webdriver-manager/built/lib/cli/logger.js:66
info(...msgs) {
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/lib/node_modules/protractor/node_modules/webdriver-manager/built/lib/cli/index.js:8:10)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)