4
votes

Having some trouble getting Detox setup in my React Native project. My project configuration is as follows:

MacOS Version: 10.14.14 Xcode 10.2.1 Command Line Tools: Version 10.2.1

package.json:

{
  "name": "AppName",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "babel-preset-react-native-stage-0": "^1.0.1",
    "detox": "^12.11.0",
    "jest": "^23.6.0",
    "jest-react-native": "^18.0.0",
    "mocha": "^6.1.4",
    "react-test-renderer": "16.3.1"
  },
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "devtools": "react-devtools --port 8091",
    "test": "jest"
  },
  "jest": {
    "preset": "react-native"
  },
  "dependencies": {
    "jail-monkey": "^2.1.1",
    "react": "16.3.1",
    "react-devtools": "^3.2.3",
    "react-native": "~0.55.2",
    "react-native-camera": "1.1.4",
    "react-native-device-info": "^0.22.5",
    "react-native-fs": "^2.13.3",
    "react-native-image-resizer": "^1.0.0",
    "react-native-mail": "^3.0.7",
    "react-native-maps": "^0.21.0",
    "react-native-permissions": "^1.1.1",
    "react-native-signature-capture": "^0.4.9",
    "react-native-sortable-list": "0.0.22",
    "react-native-sound": "^0.10.12",
    "react-native-splash-screen": "^3.1.1",
    "react-native-sqlcipher-storage": "github:axsy-dev/react-native-sqlcipher-storage",
    "react-native-swipe-gestures": "^1.0.2",
    "react-native-swipeout": "^2.3.6",
    "react-navigation": "^2.2.4",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "redux-thunk": "^2.2.0",
    "rn-fetch-blob": "^0.10.15"
  },
  "rnpm": {
    "assets": [
      "./src/assets/fonts"
    ]
  },
  "detox": {
    "configurations": {
      "ios.sim.debug": {
        "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/ProntoPOD.app",
        "build": "xcodebuild -workspace ios/ProntoPOD.xcworkspace -scheme ProntoPOD -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
        "type": "ios.simulator",
        "name": "iPhone XR"
      }
    },
    "test-runner": "jest"
  }
}

Originally I was getting the following errors occurring after installing Jest and Detox as per the instructions in the Setup Guide:

Build system information error: Multiple commands produce '': 1) Target 'double-conversion' (project 'React') has copy command from '/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/react-native/third-party/double-conversion-1.1.5/src/bignum-dtoa.h' to '/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/ios/build/Build/Products/Debug-iphonesimulator/include/double-conversion/bignum-dtoa.h' 2) Target 'double-conversion-tvOS' (project 'React') has copy command from '/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/react-native/third-party/double-conversion-1.1.5/src/bignum-dtoa.h' to '/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/ios/build/Build/Products/Debug-iphonesimulator/include/double-conversion/bignum-dtoa.h'

Build system information error: Multiple commands produce '': 1) Target 'double-conversion' (project 'React'): Libtool /Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/ios/build/Build/Products/Debug-iphonesimulator/libdouble-conversion.a normal x86_64 2) Target 'double-conversion-tvOS' (project 'React'): Libtool /Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/ios/build/Build/Products/Debug-iphonesimulator/libdouble-conversion.a normal x86_64

** BUILD FAILED **

detox[64617] ERROR: [cli.js] Error: Command failed: xcodebuild -workspace ios/ProntoPOD.xcworkspace -scheme ProntoPOD -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build

This was resolved by changing the Build System in XCode to the Legacy Build under Workspace Settings. The following error now appears and I am not sure how to resolve it:

Error: An error occurred while adding the reporter at path "/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/detox/runners/jest/streamlineReporter.js".Cannot find module '@jest/reporters' at reporters.forEach (/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/jest/node_modules/jest-cli/build/TestScheduler.js:510:15) at Array.forEach () at TestScheduler._addCustomReporters (/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/jest/node_modules/jest-cli/build/TestScheduler.js:497:15) at TestScheduler._setupReporters (/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/jest/node_modules/jest-cli/build/TestScheduler.js:466:12) at new TestScheduler (/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/jest/node_modules/jest-cli/build/TestScheduler.js:193:10) at /Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/jest/node_modules/jest-cli/build/runJest.js:452:27 at Generator.next () at step (/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/jest/node_modules/jest-cli/build/runJest.js:107:30) at /Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/jest/node_modules/jest-cli/build/runJest.js:118:15 at processTicksAndRejections (internal/process/task_queues.js:86:5) detox[64758] ERROR: [cli.js] Error: Command failed: node_modules/.bin/jest --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)*$' "e2e"

Any help would be appreciated. Thanks!

2

2 Answers

6
votes

If this is due to peer dependency, you can try npm install @jest/reporters manually since peer dependencies are not auto installed in npm 3 upwards.

0
votes

Try running

npm install @jest/reporters 
npm install