My Setup
detox : 18.0.0 jest : 26.6.3 react-native-cli : 2.0.1 nodejs : 14.15.4 npm : 6.14.10 yarn : 1.22.10 OS : ubuntu 18.04 real connected device : Samsung M 01
My init.js
const detox = require('detox');
const adapter = require('detox/runners/jest/adapter');
const specReporter = require('detox/runners/jest/specReporter');
// Set the default timeout
jest.setTimeout(2000);
jasmine.getEnv().addReporter(adapter);`enter code he`enter code here`re`
// This takes care of generating status logs on a per-spec basis. By default, jest only reports at file-level.
// This is strictly optional.
jasmine.getEnv().addReporter(specReporter);
beforeAll(async () => {
await detox.init();
device.launchApp();
}, 300000);
beforeEach(async () => {
try {
await adapter.beforeEach();
} catch (err) {
// Workaround for the 'jest-jasmine' runner (default one): if 'beforeAll' hook above fails with a timeout,
// unfortunately, 'jest' might continue running other hooks and test suites. To prevent that behavior,
// adapter.beforeEach() will throw if detox.init() is still running; that allows us to run detox.cleanup()
// in that emergency case and disable calling 'device', 'element', 'expect', 'by' and other Detox globals.
// If you switch to 'jest-circus' runner, you can omit this try-catch workaround at all.
await detox.cleanup();
throw err;
}
});
afterAll(async () => {
await adapter.afterAll();
await detox.cleanup();
});
My Package.json :
"detox": {
"configurations": {
"android.emu.debug": {
"binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
"build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
"type": "android.attached",
"device": {
"adbName":"R9BN90441KJ"
}
},
"android.emu.release": {
"binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
"build": "cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..",
"type": "android.emulator",
"name": "Test Kirana"
}
},
"specs": "e2e",
"test-runner": "jest"
},
"rnpm": {
"assets": [
"android/app/src/main/assets/fonts/Roboto/Roboto-Regular.ttf"
]
}
Please find Error messages below :
detox[10532] WARN: [Client.js/PENDING_REQUESTS] App has not responded to the network requests below:
HINT: Most likely, your tests have timed out and called detox.cleanup() while it was waiting for "ready" message (over WebSocket) from the instrumentation process.
(Use node --trace-warnings ... to show where the warning was created)
Jest did not exit one second after the test run has completed.
detox[10520] ERROR: [cli.js] Error: Command failed: jest --config e2e/config.json --testNamePattern '^((?!:ios:).)*$' --maxWorkers 1 e2e/01-placeorder_from_all_page.spec.js