Detox
Detox copied to clipboard
DetoxRuntimeError: Detox worker instance has not been installed in this context (DetoxPrimaryContext).
What happened?
When I run "yarn jest" I got this error. That's weird because when I run "detox test" works like a charm.
Error:
When I run the detox test
What was the expected behaviour?
Run all the tests without errors.
Was it tested on latest Detox?
- [X] I have tested this issue on the latest Detox release and it still reproduces.
Help us reproduce this issue!
As I said, I just run the tests and it happens.
In what environment did this happen?
Detox version: ^20.17.1 React Native version: 0.67.5 Has Fabric (React Native's new rendering system) enabled: not sure. Node version: 16.14.0 Test-runner (select one): jest / other
Detox logs
No response
Device logs
No response
More data, please!
No response
Logs?
What's in your e2e/jest.config.js?
What's in your e2e/jest.config.js?
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
preset: 'ts-jest',
rootDir: '..',
testMatch: ['<rootDir>/e2e/**/*.test.ts'],
testTimeout: 120000,
maxWorkers: 1,
globalSetup: 'detox/runners/jest/globalSetup',
globalTeardown: 'detox/runners/jest/globalTeardown',
reporters: ['detox/runners/jest/reporter'],
testEnvironment: 'detox/runners/jest/testEnvironment',
verbose: true,
}
And if you append --showConfig to your detox test ...
command, what do you see? No need to add "--record-logs all" this time
21:28:44.165 detox[76126] B jest --config e2e/jest.config.js --showConfig
{
"configs": [
{
"automock": false,
"cache": true,
"cacheDirectory": "/private/var/folders/z3/rplvj9fj7llgzt9l8gv5sb1w0000gn/T/jest_dx",
"clearMocks": false,
"collectCoverageFrom": [],
"coverageDirectory": "/Users/arthur/Dev/getahead-frontend/coverage",
"coveragePathIgnorePatterns": [
"/node_modules/"
],
"cwd": "/Users/arthur/Dev/getahead-frontend",
"detectLeaks": false,
"detectOpenHandles": false,
"errorOnDeprecated": false,
"extensionsToTreatAsEsm": [],
"fakeTimers": {
"enableGlobally": false
},
"forceCoverageMatch": [],
"globalSetup": "/Users/arthur/Dev/getahead-frontend/node_modules/detox/runners/jest/globalSetup.js",
"globalTeardown": "/Users/arthur/Dev/getahead-frontend/node_modules/detox/runners/jest/globalTeardown.js",
"globals": {},
"haste": {
"computeSha1": false,
"enableSymlinks": false,
"forceNodeFilesystemAPI": true,
"throwOnModuleCollision": false
},
"id": "a4d5d7a4ddc72ddb54efa8271fd04b1f",
"injectGlobals": true,
"moduleDirectories": [
"node_modules"
],
"moduleFileExtensions": [
"js",
"mjs",
"cjs",
"jsx",
"ts",
"tsx",
"json",
"node"
],
"moduleNameMapper": [],
"modulePathIgnorePatterns": [],
"openHandlesTimeout": 1000,
"prettierPath": "prettier",
"resetMocks": false,
"resetModules": false,
"restoreMocks": false,
"rootDir": "/Users/arthur/Dev/getahead-frontend",
"roots": [
"/Users/arthur/Dev/getahead-frontend"
],
"runner": "/Users/arthur/Dev/getahead-frontend/node_modules/jest-runner/build/index.js",
"sandboxInjectedGlobals": [],
"setupFiles": [],
"setupFilesAfterEnv": [],
"skipFilter": false,
"slowTestThreshold": 5,
"snapshotFormat": {
"escapeString": false,
"printBasicPrototype": false
},
"snapshotSerializers": [],
"testEnvironment": "/Users/arthur/Dev/getahead-frontend/node_modules/detox/runners/jest/testEnvironment/index.js",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": [
"/Users/arthur/Dev/getahead-frontend/e2e/**/*.test.ts"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"testRegex": [],
"testRunner": "/Users/arthur/Dev/getahead-frontend/node_modules/jest-circus/runner.js",
"transform": [
[
"^.+\\.tsx?$",
"/Users/arthur/Dev/getahead-frontend/node_modules/ts-jest/dist/index.js",
{}
]
],
"transformIgnorePatterns": [
"/node_modules/",
"\\.pnp\\.[^\\/]+$"
],
"watchPathIgnorePatterns": []
}
],
"globalConfig": {
"bail": 0,
"changedFilesWithAncestor": false,
"ci": false,
"collectCoverage": false,
"collectCoverageFrom": [],
"coverageDirectory": "/Users/arthur/Dev/getahead-frontend/coverage",
"coverageProvider": "babel",
"coverageReporters": [
"json",
"text",
"lcov",
"clover"
],
"detectLeaks": false,
"detectOpenHandles": false,
"errorOnDeprecated": false,
"expand": false,
"findRelatedTests": false,
"forceExit": false,
"globalSetup": "/Users/arthur/Dev/getahead-frontend/node_modules/detox/runners/jest/globalSetup.js",
"globalTeardown": "/Users/arthur/Dev/getahead-frontend/node_modules/detox/runners/jest/globalTeardown.js",
"json": false,
"lastCommit": false,
"listTests": false,
"logHeapUsage": false,
"maxConcurrency": 5,
"maxWorkers": 1,
"noStackTrace": false,
"nonFlagArgs": [],
"notify": false,
"notifyMode": "failure-change",
"onlyChanged": false,
"onlyFailures": false,
"openHandlesTimeout": 1000,
"passWithNoTests": false,
"projects": [],
"reporters": [
[
"/Users/arthur/Dev/getahead-frontend/node_modules/detox/runners/jest/reporter.js",
{}
]
],
"rootDir": "/Users/arthur/Dev/getahead-frontend",
"runTestsByPath": false,
"seed": -1047048502,
"skipFilter": false,
"snapshotFormat": {
"escapeString": false,
"printBasicPrototype": false
},
"testFailureExitCode": 1,
"testPathPattern": "",
"testSequencer": "/Users/arthur/Dev/getahead-frontend/node_modules/@jest/test-sequencer/build/index.js",
"testTimeout": 120000,
"updateSnapshot": "new",
"useStderr": false,
"verbose": true,
"watch": false,
"watchAll": false,
"watchman": true,
"workerThreads": false
},
"version": "29.7.0"
}
Hm, could you explain why do you get different configs?
This issue seems to have a dramatically wrong description. From your logs (which you have deleted), I can see that your app is busy and Detox can't wait long until it finishes its activities.
We write some basic information about it here: https://wix.github.io/Detox/docs/troubleshooting/synchronization
It can be due to Sentry/Firebase/whatever instrumenting and logging like here:
https://github.com/wix/Detox/issues/4242
It can be due to animation
https://github.com/wix/Detox/issues/4353
Try to analyze your app with Flipper, record CPU and React rendering activity, and maybe you'll find something.
I can't help further than that.
@noomorph my workaround is to disable detox tests while running jest, and run after jest is completed. I'm using a lot of libraries, one of them is "blocking" the detox. I'll try to investigate, but thank you so much for your help.
See Jest config.
https://jestjs.io/docs/configuration#testpathignorepatterns-arraystring
https://jestjs.io/docs/configuration#testmatch-arraystring
Thank you for telling why you need this. We will add that notice to the docs!
BOTTOM LINE: You don't need the workaround, you just need a proper config for your non-Detox tests.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.
Thank you for your contributions!
For more information on bots in this repository, read this discussion.