Skip to content

Commit 0868e58

Browse files
yogevbdnoomorph
andauthored
Fix detox tests (#7737)
* fix: detox config * ci: add --forceExit option * fix config * Update package.json * temp: switch to single worker * fix: retries issue and detox debug config * Revert "temp: switch to single worker" This reverts commit 4cca800. * test(detox): fix android.debug * Fix iOS tests * Update test-e2e.js --------- Co-authored-by: Yaroslav Serhieiev <[email protected]> Co-authored-by: Yaroslav Serhieiev <[email protected]>
1 parent d19f634 commit 0868e58

10 files changed

+43
-45
lines changed

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

e2e/BackButton.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ describe('Back Button', () => {
3232
await expect(elementById(TestIDs.BACK_BUTTON)).toBeNotVisible();
3333
await elementById(TestIDs.TOGGLE_BACK_BUTTON_VISIBILITY).tap();
3434
await elementById(TestIDs.DISMISS_BTN).tap();
35+
await elementByLabel('OK').tap();
3536
await elementById(TestIDs.BACK_BUTTON).tap();
3637
await expect(elementById(TestIDs.NAVIGATION_TAB)).toBeVisible();
3738
});

e2e/config.json

-11
This file was deleted.

e2e/global-setup.js

-7
This file was deleted.

e2e/global-teardown.js

-7
This file was deleted.

e2e/init.js

-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
const detox = require('detox');
2-
const config = require('../package.json').detox;
31
require('detox-testing-library-rnn-adapter').extendDetox();
4-
5-
jest.setTimeout(300000);
6-
7-
beforeAll(async () => {
8-
await detox.init(config, { launchApp: false });
9-
});
10-
11-
afterAll(async () => {
12-
await detox.cleanup();
13-
});

e2e/jest.config.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
...require('../jest.config.js'),
3+
4+
bail: true,
5+
globalSetup: 'detox/runners/jest/globalSetup',
6+
globalTeardown: 'detox/runners/jest/globalTeardown',
7+
reporters: ['detox/runners/jest/reporter'],
8+
maxWorkers: 1,
9+
moduleNameMapper: {
10+
...require('../jest.config.js').moduleNameMapper,
11+
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'identity-obj-proxy'
12+
},
13+
rootDir: '..',
14+
setupFilesAfterEnv: ['<rootDir>/e2e/init.js'],
15+
testEnvironment: 'detox/runners/jest/testEnvironment',
16+
testMatch: ['<rootDir>/e2e/**.test.{js,ts}'],
17+
testTimeout: 30000,
18+
verbose: true
19+
};

index.e2e.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { LogBox } from 'react-native';
2+
LogBox.ignoreAllLogs();
3+
4+
require('./playground/index');

package.json

+11-6
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@
8888
"@types/react-test-renderer": "16.9.2",
8989
"@typescript-eslint/eslint-plugin": "4.33.0",
9090
"@typescript-eslint/parser": "4.33.0",
91-
"babel-jest": "^29.5.0",
91+
"babel-jest": "^27.0.0",
9292
"clang-format": "^1.4.0",
9393
"detox": "20.9.0",
94-
"detox-testing-library-rnn-adapter": "2.x.x",
94+
"detox-testing-library-rnn-adapter": "^2.0.3",
9595
"eslint": "7.32.0",
9696
"eslint-config-prettier": "6.11.0",
9797
"eslint-plugin-prettier": "3.1.4",
@@ -130,8 +130,11 @@
130130
"*.{h,m,mm}": "node ./scripts/check-clang-format"
131131
},
132132
"detox": {
133-
"test-runner": "jest",
134-
"specs": "",
133+
"testRunner": {
134+
"args": {
135+
"config": "e2e/jest.config.js"
136+
}
137+
},
135138
"artifacts": {
136139
"plugins": {
137140
"log": "all",
@@ -168,7 +171,8 @@
168171
"ios.debug": {
169172
"type": "ios.app",
170173
"binaryPath": "playground/ios/DerivedData/playground/Build/Products/Debug-iphonesimulator/playground.app",
171-
"build": ":"
174+
"start": "npm start -- --e2e",
175+
"build": "RCT_NO_LAUNCH_PACKAGER=true xcodebuild build -scheme playground -workspace playground/ios/playground.xcworkspace -sdk iphonesimulator -configuration Debug -derivedDataPath playground/ios/DerivedData/playground ONLY_ACTIVE_ARCH=YES -quiet -UseModernBuildSystem=YES"
172176
},
173177
"ios.release": {
174178
"type": "ios.app",
@@ -178,6 +182,7 @@
178182
"android.debug": {
179183
"type": "android.apk",
180184
"binaryPath": "playground/android/app/build/outputs/apk/debug/app-debug.apk",
185+
"start": "npm start -- --e2e",
181186
"build": "cd playground/android && ./gradlew app:assembleDebug app:assembleAndroidTest -DtestBuildType=debug"
182187
},
183188
"android.release": {
@@ -218,4 +223,4 @@
218223
}
219224
}
220225
}
221-
}
226+
}

scripts/start.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@ const exec = require('shell-utils').exec;
22

33
const isWindows = process.platform === 'win32' ? true : false;
44

5+
const sourceExts = ['js', 'json', 'ts', 'tsx'];
6+
if (process.argv.indexOf('--e2e') > 0) {
7+
sourceExts.unshift('e2e.js');
8+
}
9+
510
if (isWindows) runWin32();
611
else run();
712

813
function run() {
914
exec.killPort(8081);
1015
exec.execSync(`watchman watch-del-all || true`);
1116
exec.execSync(`adb reverse tcp:8081 tcp:8081 || true`);
12-
exec.execSync(`node ./node_modules/react-native/local-cli/cli.js start`);
17+
exec.execSync(`node ./node_modules/react-native/local-cli/cli.js start --sourceExts ${sourceExts}`);
1318
}
1419

1520
function runWin32() {
1621
exec.execSync(`adb reverse tcp:8081 tcp:8081`);
17-
exec.execSync(`node ./node_modules/react-native/local-cli/cli.js start`);
22+
exec.execSync(`node ./node_modules/react-native/local-cli/cli.js start --sourceExts ${sourceExts}`);
1823
}

0 commit comments

Comments
 (0)