Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DetoxRuntimeError: Detox worker instance has not been installed in this context (DetoxPrimaryContext). #4362

Open
1 task done
devartwa opened this issue Feb 8, 2024 · 10 comments

Comments

@devartwa
Copy link

devartwa commented Feb 8, 2024

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:
Screenshot 2024-02-08 at 9 12 24 pm

When I run the detox test
Screenshot 2024-02-08 at 9 10 04 pm

What was the expected behaviour?

Run all the tests without errors.

Was it tested on latest Detox?

  • 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

@noomorph
Copy link
Collaborator

noomorph commented Feb 8, 2024

Logs?

@noomorph
Copy link
Collaborator

noomorph commented Feb 8, 2024

What's in your e2e/jest.config.js?

@devartwa
Copy link
Author

devartwa commented Feb 8, 2024

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,
}

@noomorph
Copy link
Collaborator

noomorph commented Feb 8, 2024

And if you append --showConfig to your detox test ... command, what do you see? No need to add "--record-logs all" this time

@devartwa
Copy link
Author

devartwa commented Feb 8, 2024

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"
}

@noomorph
Copy link
Collaborator

noomorph commented Feb 8, 2024

Hm, could you explain why do you get different configs?

image

@noomorph
Copy link
Collaborator

noomorph commented Feb 8, 2024

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.

image

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:

#4242

It can be due to animation

#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.

@devartwa
Copy link
Author

devartwa commented Feb 9, 2024

@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.

@noomorph
Copy link
Collaborator

noomorph commented Feb 9, 2024 via email

Copy link

stale bot commented Mar 17, 2024

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.

@stale stale bot added the 🏚 stale label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants