I tried adding Detox e2e testing to my react native app and I am running into the following error when trying to run a simple test.
I have only installed Detox to the iOS side of the app. The "detox build" command executed perfectly.
Below are the important files from my project.
Package.json
{
"name": "ExerFit_mobileapp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"bcrypt": "^3.0.7",
"firebase": "^5.5.9",
"moment": "^2.24.0",
"native-base": "^2.13.8",
"qs": "^6.9.0",
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-custom-tabs": "^0.1.7",
"react-native-datepicker": "^1.7.2",
"react-native-navigation": "^3.7.0",
"react-native-vector-icons": "^6.6.0",
"react-navigation": "^2.18.2",
"rn-apple-healthkit": "^0.6.5",
"switch-button-react-native": "^1.0.3"
},
"devDependencies": {
"babel-jest": "24.9.0",
"babel-preset-react-native": "4.0.1",
"detox": "^15.1.4",
"jest": "24.9.0",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
},
"detox": {
"test-runner": "jest",
"specs": "e2e",
"configurations": {
"ios.sim.debug": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/ExerFit_mobileapp.app",
"build": "xcodebuild -workspace ios/ExerFit_mobileapp.xcworkspace -scheme ExerFit_mobileapp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"name": "iPhone 7"
}
}
}
}
config.json
{
"setupFilesAfterEnv": ["./init.js"],
"testEnvironment": "node",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true
}
init.js
const detox = require('detox');
const config = require('../package.json').detox;
const adapter = require('detox/runners/jest/adapter');
const specReporter = require('detox/runners/jest/specReporter');
jest.setTimeout(120000);
jasmine.getEnv().addReporter(adapter);
jasmine.getEnv().addReporter(specReporter);
beforeAll(async () => {
await detox.init(config);
}, 300000);
beforeEach(async () => {
await adapter.beforeEach();
});
afterAll(async () => {
await adapter.afterAll();
await detox.cleanup();
});