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

Could not resolve a module for a custom reporter #4170

Open
MrShakes opened this issue Aug 23, 2023 · 21 comments
Open

Could not resolve a module for a custom reporter #4170

MrShakes opened this issue Aug 23, 2023 · 21 comments

Comments

@MrShakes
Copy link

Description

Already posted on SO here
I just upgraded my Detox from ^18.6.2 to ^20.11.3 and Jest from ^26.6.3 to ^29.
Followed the migration docs. detox build works well however when I try to run detox test I get the error below

Error: Could not resolve a module for a custom reporter.
  Module name: detox/runners/jest/reporter
    at /<path>/node_modules/jest-config/build/normalize.js:426:15

My config.js file is as below:

module.exports = {
  maxWorkers: 1,
  testTimeout: 120000,
  rootDir: "..",
  testMatch: ["<rootDir>/e2e/**/*.e2e.js"],
  verbose: true,
  reporters: ["detox/runners/jest/reporter"],
  globalSetup: "detox/runners/jest/globalSetup",
  globalTeardown: "detox/runners/jest/globalTeardown",
  testEnvironment: "detox/runners/jest/testEnvironment",
};

detoxrc.json

{
  "testRunner": {
    "$0": "jest",
    "args": {
    "config": "e2e/config.js",
    "_": ["e2e"]
    },
    "jest": {
      "setupTimeout": 120000,
      "reportSpecs": false,
      "reportWorkerAssign": false
    }
  },
  "apps": {
    "ios-debug": { 
      "type": "ios.app",
      "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/Pumpables.app",
      "build": "xcodebuild -workspace ios/Pumpables.xcworkspace -scheme Pumpables -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build"
    },
    "ios-release": {
      "type": "ios.app",
      "binaryPath": "ios/build/Build/Products/Release-iphonesimulator/Pumpables.app",
      "build": "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/Pumpables.xcworkspace -scheme Pumpables -configuration Release -sdk iphonesimulator -derivedDataPath ios/build"
    },
  },
  "devices": {
    "simulator": {
      "type": "ios.simulator",
      "device": {
        "type": "iPhone 11"
      }
    }
  },
  "configurations": {
    "ios-debug": {
      "device": "simulator",
      "app": "ios-debug"
    },
    "ios-release": {
      "device": "simulator",
      "app": "ios-release"
    }
  }
}

Node 14.17.6 npm 6.14.15, also tried with a higher node version(20.5.0) and that didn't work either

Your environment

Detox version: 20.11.3
React Native version: 0.70.4
Node version: 14.17.6
Device model: macOS 12.4
OS: IOS
Test-runner: Jest 29

@noomorph
Copy link
Collaborator

Do you have something at /<path>/node_modules/detox/?

Could you print here its package.json?

@MrShakes
Copy link
Author

Yes,

{
  "name": "detox",
  "description": "E2E tests and automation for mobile",
  "version": "18.23.1",
  "bin": {
    "detox": "local-cli/cli.js"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/wix/Detox.git"
  },
  "nativePackage": true,
  "bugs": {
    "url": "https://github.com/wix/Detox/issues"
  },
  "homepage": "https://github.com/wix/Detox#readme",
  "main": "./src/index.js",
  "types": "./index.d.ts",
  "author": "Tal Kol <talkol@gmail.com>",
  "license": "MIT",
  "scripts": {
    "build": ":",
    "build:android": "cd android && ./gradlew publish -Dversion=999.999.999 && cd ..",
    "build:android-native": "cd android && ./gradlew publish -Dversion=999.999.999 -DbuildFlavour=coreNative -DforceLocal=true && cd ..",
    "lint": "eslint local-cli runners src scripts",
    "unit": "jest --coverage --verbose",
    "pretest": "npm run lint",
    "test": "npm run unit",
    "posttest": "cp coverage/lcov.info coverage/unit.lcov",
    "unit:watch": "jest --watch",
    "prepublish": "npm run build",
    "postinstall": "node scripts/postinstall.js"
  },
  "devDependencies": {
    "@types/child-process-promise": "^2.2.1",
    "@types/ws": "^7.4.0",
    "eslint": "^4.11.0",
    "eslint-plugin-import": "^2.23.3",
    "eslint-plugin-no-only-tests": "^2.6.0",
    "eslint-plugin-node": "^6.0.1",
    "jest": "^27.0.0",
    "jest-environment-node": "^27.0.0",
    "mocha": ">=6.0.0",
    "mockdate": "^2.0.1",
    "prettier": "1.7.0",
    "react-native": "0.64.1",
    "react-native-codegen": "^0.0.8",
    "wtfnode": "^0.8.0"
  },
  "dependencies": {
    "bunyan": "^1.8.12",
    "bunyan-debug-stream": "^1.1.0",
    "chalk": "^2.4.2",
    "child-process-promise": "^2.2.0",
    "find-up": "^4.1.0",
    "fs-extra": "^4.0.2",
    "funpermaproxy": "^1.0.1",
    "get-port": "^2.1.0",
    "ini": "^1.3.4",
    "lodash": "^4.17.5",
    "minimist": "^1.2.0",
    "proper-lockfile": "^3.0.2",
    "resolve-from": "^5.0.0",
    "sanitize-filename": "^1.6.1",
    "semver": "^7.0.0",
    "serialize-error": "^8.0.1",
    "shell-quote": "^1.7.2",
    "signal-exit": "^3.0.3",
    "tail": "^2.0.0",
    "telnet-client": "1.2.8",
    "tempfile": "^2.0.0",
    "which": "^1.3.1",
    "ws": "^7.0.0",
    "yargs": "^16.0.3",
    "yargs-unparser": "^2.0.0"
  },
  "peerDependencies": {
    "jest-circus": "26.0.x - 26.4.x || >=26.5.2",
    "jest-environment-node": ">=25.0.0",
    "mocha": ">=6.0.0"
  },
  "engines": {
    "node": ">=8.3.0"
  },
  "jest": {
    "setupFiles": [
      "<rootDir>/__tests__/setupJest.js"
    ],
    "testEnvironment": "node",
    "testRunner": "jest-circus/runner",
    "roots": [
      "node_modules",
      "src",
      "local-cli"
    ],
    "testPathIgnorePatterns": [
      "/node_modules/",
      "local-cli/test.js"
    ],
    "coveragePathIgnorePatterns": [
      "/node_modules/",
      "__tests__",
      ".test.js$",
      ".mock.js$",
      "local-cli/utils",
      "src/android/espressoapi",
      "src/artifacts/log",
      "src/artifacts/screenshot",
      "src/artifacts/video",
      "src/devices/drivers/DeviceDriverBase.js",
      "src/devices/drivers/android/AndroidDriver.js",
      "src/devices/drivers/android/emulator/EmulatorDriver.js",
      "src/devices/drivers/android/emulator/helpers/EmulatorLauncher.js",
      "src/devices/drivers/android/exec/AAPT.js",
      "src/devices/drivers/android/exec/ADB.js",
      "src/devices/drivers/android/exec/EmulatorExec.js",
      "src/devices/drivers/android/tools/EmulatorTelnet.js",
      "src/devices/drivers/ios",
      "src/devices/drivers/ios/tools",
      "src/utils/MissingDetox.js",
      "src/utils/appdatapath.js",
      "src/utils/debug.js",
      "src/utils/environment.js",
      "src/utils/logger.js",
      "src/utils/pipeCommands.js",
      "src/utils/pressAnyKey.js",
      "src/utils/shellUtils.js"
    ],
    "resetMocks": true,
    "resetModules": true,
    "coverageReporters": [
      "html",
      "json",
      "text",
      "clover",
      [
        "lcov",
        {
          "projectRoot": ".."
        }
      ]
    ],
    "coverageThreshold": {
      "global": {
        "statements": 100,
        "branches": 100,
        "functions": 100,
        "lines": 100
      }
    }
  },
  "gitHead": "3a01fb490e836ebd4441d62794680e750ab9948f"
}

@noomorph
Copy link
Collaborator

As you see, you have an outdated version of Detox, not 20.x but 18.x. Please sort out your dependency issues.

@MrShakes
Copy link
Author

Thanks, never encountered this before, my root package.json and yarn.lock files have the 20.x version, I'll sort it out thanks

@MrShakes
Copy link
Author

@noomorph my sincere apologies, I had switched branches to work on something else, this is the correct detox package.json, issue still occurring

{
  "name": "detox",
  "description": "E2E tests and automation for mobile",
  "version": "20.11.3",
  "bin": {
    "detox": "local-cli/cli.js"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/wix/Detox.git"
  },
  "nativePackage": true,
  "bugs": {
    "url": "https://github.com/wix/Detox/issues"
  },
  "homepage": "https://github.com/wix/Detox#readme",
  "main": "./index.js",
  "types": "./index.d.ts",
  "author": "Tal Kol <talkol@gmail.com>",
  "license": "MIT",
  "scripts": {
    "build": ":",
    "build:android": "cd android && ./gradlew publish -Dversion=999.999.999 && cd ..",
    "build:android-native": "cd android && ./gradlew publish -Dversion=999.999.999 -DbuildFlavour=coreNative -DforceLocal=true && cd ..",
    "lint": "eslint .",
    "unit": "jest --coverage --verbose",
    "unit:android-debug": "cd android && ./gradlew testFullDebug",
    "unit:android-release": "cd android && ./gradlew testFullRelease",
    "pretest": "npm run lint",
    "test": "npm run unit",
    "posttest": "cp coverage/lcov.info coverage/unit.lcov",
    "unit:watch": "jest --watch",
    "prepublish": "npm run build",
    "postinstall": "node scripts/postinstall.js"
  },
  "devDependencies": {
    "@types/bunyan": "^1.8.8",
    "@types/child-process-promise": "^2.2.1",
    "@types/fs-extra": "^9.0.13",
    "@types/jest": "^28.1.8",
    "@types/node": "^14.18.33",
    "@types/node-ipc": "^9.2.0",
    "@types/ws": "^7.4.0",
    "@typescript-eslint/eslint-plugin": "^5.59.8",
    "@typescript-eslint/parser": "^5.59.8",
    "cross-env": "^7.0.3",
    "eslint": "^8.41.0",
    "eslint-plugin-ecmascript-compat": "^3.0.0",
    "eslint-plugin-import": "^2.27.5",
    "eslint-plugin-no-only-tests": "^3.1.0",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-unicorn": "^47.0.0",
    "jest": "^28.1.3",
    "jest-allure2-reporter": "^1.2.1",
    "mockdate": "^2.0.1",
    "prettier": "^2.4.1",
    "react-native": "0.71.10",
    "react-native-codegen": "^0.0.8",
    "typescript": "^4.5.2",
    "wtfnode": "^0.9.1"
  },
  "dependencies": {
    "ajv": "^8.6.3",
    "bunyan": "^1.8.12",
    "bunyan-debug-stream": "^3.1.0",
    "caf": "^15.0.1",
    "chalk": "^4.0.0",
    "child-process-promise": "^2.2.0",
    "execa": "^5.1.1",
    "find-up": "^5.0.0",
    "fs-extra": "^11.0.0",
    "funpermaproxy": "^1.1.0",
    "glob": "^8.0.3",
    "ini": "^1.3.4",
    "json-cycle": "^1.3.0",
    "lodash": "^4.17.11",
    "multi-sort-stream": "^1.0.3",
    "multipipe": "^4.0.0",
    "node-ipc": "9.2.1",
    "proper-lockfile": "^3.0.2",
    "resolve-from": "^5.0.0",
    "sanitize-filename": "^1.6.1",
    "semver": "^7.0.0",
    "serialize-error": "^8.0.1",
    "shell-quote": "^1.7.2",
    "signal-exit": "^3.0.3",
    "stream-json": "^1.7.4",
    "strip-ansi": "^6.0.1",
    "telnet-client": "1.2.8",
    "tempfile": "^2.0.0",
    "trace-event-lib": "^1.3.1",
    "which": "^1.3.1",
    "ws": "^7.0.0",
    "yargs": "^17.0.0",
    "yargs-parser": "^21.0.0",
    "yargs-unparser": "^2.0.0"
  },
  "peerDependencies": {
    "jest": "29.x.x || 28.x.x || ^27.2.5"
  },
  "peerDependenciesMeta": {
    "jest": {
      "optional": true
    }
  },
  "engines": {
    "node": ">=14.5.0"
  },
  "jest": {
    "setupFiles": [
      "<rootDir>/__tests__/setupJest.js"
    ],
    "testEnvironment": "node",
    "testRunner": "jest-circus/runner",
    "roots": [
      "node_modules",
      "local-cli",
      "src",
      "runners"
    ],
    "testPathIgnorePatterns": [
      "/node_modules/",
      "local-cli/test.js"
    ],
    "coveragePathIgnorePatterns": [
      "/node_modules/",
      "__tests__",
      ".test.js$",
      ".mock.js$",
      "index.js",
      "internals.js",
      "local-cli/utils",
      "src/environmentFactory",
      "src/android/espressoapi",
      "src/artifacts/factories/index.js",
      "src/artifacts/providers/index.js",
      "src/artifacts/log",
      "src/artifacts/screenshot",
      "src/artifacts/video",
      "src/devices/allocation/drivers/AllocationDriverBase.js",
      "src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js",
      "src/devices/allocation/drivers/android/emulator/patchAvdSkinConfig.js",
      "src/devices/allocation/drivers/ios",
      "src/devices/allocation/factories",
      "src/devices/allocation/factories/drivers",
      "src/devices/cookies",
      "src/devices/common/drivers/android/exec/ADB.js",
      "src/devices/common/drivers/android/emulator/exec/EmulatorExec.js",
      "src/devices/common/drivers/android/tools/EmulatorTelnet.js",
      "src/devices/common/drivers/ios/tools",
      "src/devices/runtime/drivers/android/AndroidDriver.js",
      "src/devices/runtime/drivers/android/emulator/EmulatorDriver.js",
      "src/devices/runtime/drivers/DeviceDriverBase.js",
      "src/devices/runtime/drivers/ios",
      "src/devices/runtime/factories",
      "src/devices/runtime/factories/drivers",
      "src/matchers/factories",
      "src/validation/EnvironmentValidatorBase.js",
      "src/validation/factories",
      "src/validation/ios/IosSimulatorEnvValidator",
      "src/utils/appdatapath.js",
      "src/utils/debug.js",
      "src/utils/environment.js",
      "src/utils/logger.js",
      "src/utils/pipeCommands.js",
      "src/utils/pressAnyKey.js",
      "src/utils/shellUtils.js",
      "runners/jest/reporters",
      "runners/jest/testEnvironment",
      "src/DetoxWorker.js",
      "src/logger/utils/streamUtils.js",
      "src/realms"
    ],
    "resetMocks": true,
    "resetModules": true,
    "reporters": [
      "default",
      [
        "jest-allure2-reporter",
        {
          "getEnvironmentInfo": false
        }
      ]
    ],
    "coverageReporters": [
      "html",
      "json",
      "text",
      "clover",
      [
        "lcov",
        {
          "projectRoot": ".."
        }
      ]
    ],
    "coverageThreshold": {
      "global": {
        "statements": 100,
        "branches": 100,
        "functions": 100,
        "lines": 100
      }
    }
  },
  "browserslist": [
    "node 14"
  ],
  "gitHead": "4f930c48a5260627cb065707d917ee98e81b7ced"
}

@noomorph noomorph reopened this Aug 24, 2023
@noomorph
Copy link
Collaborator

Please reinstall your node modules and verify that you are experiencing exactly the same issue as originally

@MrShakes
Copy link
Author

I have done this

@noomorph
Copy link
Collaborator

From your project root directory, run

node -p "require('detox/runners/jest/reporter')"

@MrShakes
Copy link
Author

[class DetoxReporter extends VerboseReporter]

@noomorph
Copy link
Collaborator

I think it is impossible to get this error then. Are you sure?

Error: Could not resolve a module for a custom reporter.
  Module name: detox/runners/jest/reporter
    at /<path>/node_modules/jest-config/build/normalize.js:426:15

@MrShakes
Copy link
Author

Yeah

> detox test -c ios-debug

19:22:38.801 detox[81657] B jest --config e2e/config.js e2e
Error: Could not resolve a module for a custom reporter.
  Module name: detox/runners/jest/reporter
    at /<path>/node_modules/jest-config/build/normalize.js:426:15
    at Array.map (<anonymous>)
    at normalizeReporters (/<path>/node_modules/jest-config/build/normalize.js:409:20)
    at /<path>/node_modules/jest-config/build/normalize.js:747:17
    at Array.reduce (<anonymous>)
    at normalize (/<path>/node_modules/jest-config/build/normalize.js:608:14)
    at readConfig (/<path>/node_modules/jest-config/build/index.js:160:74)
    at async readConfigs (/<path>/node_modules/jest-config/build/index.js:423:26)
    at async runCLI (/<path>/node_modules/@jest/core/build/cli/index.js:151:59)
    at async Object.run (/<path>/node_modules/jest-cli/build/run.js:124:37)
19:22:39.277 detox[81657] E Command failed with exit code = 1:
jest --config e2e/config.js e2e
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Pumpables@0.5.0 test:e2e: `detox test -c ios-debug`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the Pumpables@0.5.0 test:e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /<path>/.npm/_logs/2023-08-24T18_22_39_314Z-debug.log

The debug.log file

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/<path>/.nvm/versions/node/v14.17.6/bin/node',
1 verbose cli   '/<path>/.nvm/versions/node/v14.17.6/bin/npm',
1 verbose cli   'run',
1 verbose cli   'test:e2e'
1 verbose cli ]
2 info using npm@6.14.15
3 info using node@v14.17.6
4 verbose run-script [ 'pretest:e2e', 'test:e2e', 'posttest:e2e' ]
5 info lifecycle Pumpables@0.5.0~pretest:e2e: Pumpables@0.5.0
6 info lifecycle Pumpables@0.5.0~test:e2e: Pumpables@0.5.0
7 verbose lifecycle Pumpables@0.5.0~test:e2e: unsafe-perm in lifecycle true
8 verbose lifecycle Pumpables@0.5.0~test:e2e: PATH: /<path>/.nvm/versions/node/v14.17.6/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/<path>/node_modules/.bin:/<path>/opt/anaconda3/bin:/<path>/opt/anaconda3/condabin:/<path>/.nvm/versions/node/v14.17.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/<path>/Library/Android/sdk/emulator:/<path>/Library/Android/sdk/tools:/<path>/Library/Android/sdk/tools/bin:/<path>/Library/Android/sdk/platform-tools
9 verbose lifecycle Pumpables@0.5.0~test:e2e: CWD: /<path>
10 silly lifecycle Pumpables@0.5.0~test:e2e: Args: [ '-c', 'detox test -c ios-debug' ]
11 silly lifecycle Pumpables@0.5.0~test:e2e: Returned: code: 1  signal: null
12 info lifecycle Pumpables@0.5.0~test:e2e: Failed to exec test:e2e script
13 verbose stack Error: Pumpables@0.5.0 test:e2e: `detox test -c ios-debug`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/<path>/.nvm/versions/node/v14.17.6/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:400:28)
13 verbose stack     at ChildProcess.<anonymous> (/<path>/.nvm/versions/node/v14.17.6/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:400:28)
13 verbose stack     at maybeClose (internal/child_process.js:1055:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid Pumpables@0.5.0
15 verbose cwd /<path>
16 verbose Darwin 21.5.0
17 verbose argv "/<path>/.nvm/versions/node/v14.17.6/bin/node" "/<path>/.nvm/versions/node/v14.17.6/bin/npm" "run" "test:e2e"
18 verbose node v14.17.6
19 verbose npm  v6.14.15
20 error code ELIFECYCLE
21 error errno 1
22 error Pumpables@0.5.0 test:e2e: `detox test -c ios-debug`
22 error Exit status 1
23 error Failed at the Pumpables@0.5.0 test:e2e script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

@noomorph
Copy link
Collaborator

Could you please upgrade your Node.js to 14.21.3 and if that does not help - run your detox command with --debug:

detox test -c ios-debug --debug

It should print the entire resolved Jest config in runtime. I want to check it out.

@MrShakes
Copy link
Author

> detox test -c ios-debug --debug

20:01:11.869 detox[82701] B jest --config e2e/config.js --debug e2e
Error: Could not resolve a module for a custom reporter.
  Module name: detox/runners/jest/reporter
    at /<path>/node_modules/jest-config/build/normalize.js:426:15
    at Array.map (<anonymous>)
    at normalizeReporters (/<path>/node_modules/jest-config/build/normalize.js:409:20)
    at /<path>/node_modules/jest-config/build/normalize.js:747:17
    at Array.reduce (<anonymous>)
    at normalize (/<path>/node_modules/jest-config/build/normalize.js:608:14)
    at readConfig (/<path>/node_modules/jest-config/build/index.js:160:74)
    at async readConfigs (/<path>/node_modules/jest-config/build/index.js:423:26)
    at async runCLI (/<path>/node_modules/@jest/core/build/cli/index.js:151:59)
    at async Object.run (/<path>/node_modules/jest-cli/build/run.js:124:37)
20:01:12.321 detox[82701] E Command failed with exit code = 1:
jest --config e2e/config.js --debug e2e
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Pumpables@0.5.0 test:e2e: `detox test -c ios-debug --debug`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the Pumpables@0.5.0 test:e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /<path>/.npm/_logs/2023-08-24T19_01_12_358Z-debug.log

debug.log file

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/<path>/.nvm/versions/node/v14.21.3/bin/node',
1 verbose cli   '/<path>/.nvm/versions/node/v14.21.3/bin/npm',
1 verbose cli   'run',
1 verbose cli   'test:e2e'
1 verbose cli ]
2 info using npm@6.14.18
3 info using node@v14.21.3
4 verbose run-script [ 'pretest:e2e', 'test:e2e', 'posttest:e2e' ]
5 info lifecycle Pumpables@0.5.0~pretest:e2e: Pumpables@0.5.0
6 info lifecycle Pumpables@0.5.0~test:e2e: Pumpables@0.5.0
7 verbose lifecycle Pumpables@0.5.0~test:e2e: unsafe-perm in lifecycle true
8 verbose lifecycle Pumpables@0.5.0~test:e2e: PATH: /<path>/.nvm/versions/node/v14.21.3/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/<path>/node_modules/.bin:/<path>/opt/anaconda3/bin:/<path>/opt/anaconda3/condabin:/<path>/.nvm/versions/node/v14.21.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/<path>/Library/Android/sdk/emulator:/<path>/Library/Android/sdk/tools:/<path>/Library/Android/sdk/tools/bin:/<path>/Library/Android/sdk/platform-tools
9 verbose lifecycle Pumpables@0.5.0~test:e2e: CWD: /<path>
10 silly lifecycle Pumpables@0.5.0~test:e2e: Args: [ '-c', 'detox test -c ios-debug --debug' ]
11 silly lifecycle Pumpables@0.5.0~test:e2e: Returned: code: 1  signal: null
12 info lifecycle Pumpables@0.5.0~test:e2e: Failed to exec test:e2e script
13 verbose stack Error: Pumpables@0.5.0 test:e2e: `detox test -c ios-debug --debug`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/<path>/.nvm/versions/node/v14.21.3/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:400:28)
13 verbose stack     at ChildProcess.<anonymous> (/<path>/.nvm/versions/node/v14.21.3/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:400:28)
13 verbose stack     at maybeClose (internal/child_process.js:1088:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5)
14 verbose pkgid Pumpables@0.5.0
15 verbose cwd /<path>
16 verbose Darwin 21.5.0
17 verbose argv "/<path>/.nvm/versions/node/v14.21.3/bin/node" "/<path>/.nvm/versions/node/v14.21.3/bin/npm" "run" "test:e2e"
18 verbose node v14.21.3
19 verbose npm  v6.14.18
20 error code ELIFECYCLE
21 error errno 1
22 error Pumpables@0.5.0 test:e2e: `detox test -c ios-debug --debug`
22 error Exit status 1
23 error Failed at the Pumpables@0.5.0 test:e2e script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

@noomorph
Copy link
Collaborator

hmm ok 🧐

try --showConfig instead of --debug

@MrShakes
Copy link
Author

> detox test -c ios-debug --showConfig

20:31:15.218 detox[83064] B jest --config e2e/config.js --showConfig e2e
Error: Could not resolve a module for a custom reporter.
  Module name: detox/runners/jest/reporter
    at /<path>/node_modules/jest-config/build/normalize.js:426:15
    at Array.map (<anonymous>)
    at normalizeReporters (/<path>/node_modules/jest-config/build/normalize.js:409:20)
    at /<path>/node_modules/jest-config/build/normalize.js:747:17
    at Array.reduce (<anonymous>)
    at normalize (/<path>/node_modules/jest-config/build/normalize.js:608:14)
    at readConfig (/<path>/node_modules/jest-config/build/index.js:160:74)
    at async readConfigs (/<path>/node_modules/jest-config/build/index.js:423:26)
    at async runCLI (/<path>/node_modules/@jest/core/build/cli/index.js:151:59)
    at async Object.run (/<path>/node_modules/jest-cli/build/run.js:124:37)
20:31:15.664 detox[83064] E Command failed with exit code = 1:
jest --config e2e/config.js --showConfig e2e

@noomorph
Copy link
Collaborator

So, it fails earlier than it can show a config. I don't know how to help. 😕 I'd start debugging that function, perhaps:

normalizeReporters (//node_modules/jest-config/build/normalize.js:409:20

No idea why it doesn't like the path. It should work 🤷‍♂️

@MrShakes
Copy link
Author

Ok, will check it, thanks for your help

Copy link

stale bot commented Dec 15, 2023

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 Dec 15, 2023
@carolina-vromo
Copy link

carolina-vromo commented Oct 9, 2024

I have exactly the same problem. I'm using
Detox version: 20.11.3
React Native version: 0.74.5
Node version: >18 (22.8.0)
Device model: macOS M3
Test-runner: Jest 29
JVM 17.0.1
When I run node -p "require('detox/runners/jest/reporter')" I see the module
[class DetoxReporter extends VerboseReporter]

e2e/jest.config.js

/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
  rootDir: '..',
  testTimeout: 120000,
  maxWorkers: 1,
  testMatch: ['<rootDir>/e2e/**/*.test.ts'],
  verbose: true,
  reporters: ['detox/runners/jest/reporter'],
  globalSetup: 'detox/runners/jest/globalSetup',
  globalTeardown: 'detox/runners/jest/globalTeardown',
  testEnvironment: 'detox/runners/jest/testEnvironment',
};

and my .detoxrc.js (at root level)

/** @type {Detox.DetoxConfig} */
module.exports = {
  testRunner: {
    $0: 'jest',
    args: {
      config: 'e2e/jest.config.js',
      _: ['e2e']
    },
    jest: {
      setupTimeout: 120000,
      reportSpecs: false,
      reportWorkerAssign: false,
    }
  },
  apps: {
    "ios.debug": {
      type: "ios.app",
      binaryPath: "ios/build/Build/Products/Debug-iphonesimulator/YOUR_APP.app",
      build: "xcodebuild -workspace ios/YOUR_APP.xcworkspace -scheme YOUR_APP -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build"
    },
    "ios.release": {
      type: "ios.app",
      binaryPath: "ios/build/Build/Products/Release-iphonesimulator/YOUR_APP.app",
      build: "xcodebuild -workspace ios/YOUR_APP.xcworkspace -scheme YOUR_APP -configuration Release -sdk iphonesimulator -derivedDataPath ios/build"
    },
    "android.debug": {
      type: "android.apk",
      binaryPath: "android/app/build/outputs/apk/debug/app-debug.apk",
      build: "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug",
      reversePorts: [
        8081
      ]
    },
    "android.release": {
      type: "android.apk",
      binaryPath: "android/app/build/outputs/apk/release/app-release.apk",
      build: "cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release"
    }
  },
  devices: {
    simulator: {
      type: "ios.simulator",
      device: {
        type: "iPhone 15"
      }
    },
    attached: {
      type: "android.attached",
      device: {
        adbName: ".*"
      }
    },
    emulator: {
      type: "android.emulator",
      device: {
        avdName: "Medium_Phone_API_35"
      }
    }
  },
  configurations: {
    'ios.sim.debug': {
      device: 'simulator',
      app: 'ios.debug'
    },
    'ios.sim.release': {
      device: 'simulator',
      app: 'ios.release'
    },
    'android.att.debug': {
      device: 'attached',
      app: 'android.debug'
    },
    'android.att.release': {
      device: 'attached',
      app: 'android.release'
    },
    'android.emu.debug': {
      device: 'emulator',
      app: 'android.debug'
    },
    'android.emu.release': {
      device: 'emulator',
      app: 'android.release'
    }
  }
};

When I run detox test --configuration android.emu.debug I get Error: Could not resolve a module for a custom reporter. Module name: detox/runners/jest/reporter

@stale stale bot removed the 🏚 stale label Oct 9, 2024
@carolina-vromo
Copy link

carolina-vromo commented Oct 10, 2024

I debugged node modules file and I found that the reporter is null.

const reporter = _jestResolve().default.findNodeModule(reporterPath, {
        basedir: rootDir
      });

'reporterPath` is detox/runners/jest/reporter and rootDir is the projectDir

myproject/
├── e2e/
│ └── jest.config.js
├── node_modules/
├── package.json
├── tsconfig.json
└── ... other project files ...

If I comment the line of the reporters in jest.config works (default) but then another error is thrown.

Error: Validation Error:

  Module /Users/carolina/Documents/Repos/spatula-go/node_modules/babel-jest/build/index.js in the transform option was not found.

@carolina-vromo
Copy link

I changed to use ts (https://wix.github.io/Detox/docs/guide/typescript/) and I found the solution here: #3771 (comment) . Removing dependency from package.json:
"resolutions": { "graceful-fs": "X.X.X" },

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

3 participants