Skip to content

Commit 3d4592c

Browse files
authored
add detox (#1267)
1 parent cb22b33 commit 3d4592c

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

example/e2e/config.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"testEnvironment": "./environment",
3+
"testRunner": "jest-circus/runner",
4+
"testTimeout": 120000,
5+
"testRegex": "\\.e2e\\.js$",
6+
"reporters": ["detox/runners/jest/streamlineReporter"],
7+
"verbose": true
8+
}

example/e2e/environment.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const {
2+
DetoxCircusEnvironment,
3+
SpecReporter,
4+
WorkerAssignReporter,
5+
} = require('detox/runners/jest-circus');
6+
7+
class CustomDetoxEnvironment extends DetoxCircusEnvironment {
8+
constructor(config, context) {
9+
super(config, context);
10+
11+
// Can be safely removed, if you are content with the default value (=300000ms)
12+
this.initTimeout = 300000;
13+
14+
// This takes care of generating status logs on a per-spec basis. By default, Jest only reports at file-level.
15+
// This is strictly optional.
16+
this.registerListeners({
17+
SpecReporter,
18+
WorkerAssignReporter,
19+
});
20+
}
21+
}
22+
23+
module.exports = CustomDetoxEnvironment;

example/e2e/firstTest.e2e.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
describe('Maps Example App', () => {
2+
beforeAll(async () => {
3+
await device.launchApp();
4+
});
5+
6+
afterEach(async () => {
7+
await device.reloadReactNative();
8+
});
9+
10+
it('should show initial screen', async () => {
11+
await expect(element(by.text('Map'))).toBeVisible();
12+
await expect(element(by.text('Camera'))).toBeVisible();
13+
await expect(element(by.text('User Location'))).toBeVisible();
14+
});
15+
});

example/package.json

+41
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@
5252
"@typescript-eslint/parser": "^4.14.0",
5353
"babel-jest": "^26.6.3",
5454
"babel-plugin-module-resolver": "^4.1.0",
55+
"detox": "^18.7.1",
5556
"eslint": "^7.3.0",
5657
"eslint-config-prettier": "^8.1.0",
5758
"eslint-plugin-import": "^2.22.0",
5859
"glob-to-regexp": "^0.4.0",
5960
"jest": "^26.6.3",
61+
"jest-circus": "^26.6.3",
6062
"jetifier": "^1.6.4",
6163
"metro-react-native-babel-preset": "^0.64.0",
6264
"react-test-renderer": "16.13.1",
@@ -67,5 +69,44 @@
6769
"setupFilesAfterEnv": [
6870
"../setup-jest"
6971
]
72+
},
73+
"detox": {
74+
"testRunner": "jest",
75+
"runnerConfig": "e2e/config.json",
76+
"apps": {
77+
"ios": {
78+
"type": "ios.app",
79+
"build": "xcodebuild CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=\"NO\" CODE_SIGN_ENTITLEMENTS=\"\" CODE_SIGNING_ALLOWED=\"NO\" -workspace ios/RNMapboxGLExample.xcworkspace -configuration Debug -scheme RNMapboxGLExample -derivedDataPath ios/build",
80+
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/RNMapboxGLExample.app"
81+
},
82+
"android": {
83+
"type": "android.apk",
84+
"binaryPath": "SPECIFY_PATH_TO_YOUR_APP_BINARY"
85+
}
86+
},
87+
"devices": {
88+
"simulator": {
89+
"type": "ios.simulator",
90+
"device": {
91+
"type": "iPhone 11"
92+
}
93+
},
94+
"emulator": {
95+
"type": "android.emulator",
96+
"device": {
97+
"avdName": "Pixel_3a_API_30_x86"
98+
}
99+
}
100+
},
101+
"configurations": {
102+
"ios": {
103+
"device": "simulator",
104+
"app": "ios"
105+
},
106+
"android": {
107+
"device": "emulator",
108+
"app": "android"
109+
}
110+
}
70111
}
71112
}

0 commit comments

Comments
 (0)