Skip to content

Commit 9451901

Browse files
wip
1 parent 7cdde4d commit 9451901

File tree

7 files changed

+130
-0
lines changed

7 files changed

+130
-0
lines changed

nodejs-detox-test/.detoxrc.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"testRunner": "jest",
3+
"runnerConfig": "e2e/config.json",
4+
"skipLegacyWorkersInjection": true,
5+
"apps": {
6+
"ios": {
7+
"type": "ios.app",
8+
"binaryPath": "SPECIFY_PATH_TO_YOUR_APP_BINARY"
9+
},
10+
"android": {
11+
"type": "android.apk",
12+
"binaryPath": "SPECIFY_PATH_TO_YOUR_APP_BINARY"
13+
}
14+
},
15+
"devices": {
16+
"simulator": {
17+
"type": "ios.simulator",
18+
"device": {
19+
"type": "iPhone 11"
20+
}
21+
},
22+
"emulator": {
23+
"type": "android.emulator",
24+
"device": {
25+
"avdName": "Pixel_3a_API_30_x86"
26+
}
27+
}
28+
},
29+
"configurations": {
30+
"ios": {
31+
"device": "simulator",
32+
"app": "ios"
33+
},
34+
"android": {
35+
"device": "emulator",
36+
"app": "android"
37+
}
38+
}
39+
}

nodejs-detox-test/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-include ../.env
2+
3+
node_modules:
4+
npm install
5+
6+
test: node_modules
7+
API_KEY=$(API_KEY) npm t

nodejs-detox-test/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# NodeJS Detox email test example
2+
3+
![detox](https://www.mailslurp.com/assets/detox.png)
4+
5+
Detox is an end-to-end test runner [from Wix](https://wix.github.io/Detox/docs/introduction/getting-started/) that is similar to [Cypress](https://www.mailslurp.com/examples/cypress-js/) and [Selenium](https://www.mailslurp.com/examples/receive-emails-in-java-selenium-tests/)
6+
You can use Detox to test mobile applications. It is cross-platform and pluggable with different Javascript based test runners. With MailSlurp's SDK you can create real email addresses in tests to send and receive email verifications and login codes during testing. In this example we will cover how to test user sign up and login processes using Detox and Jest.
7+
8+
## Install Detox
9+
Make sure you have [NodeJS](https://nodejs.org/en/download/) installed then run:
10+
11+
```bash
12+
npm install detox --save-dev
13+
```
14+
15+
Then add a configuration file `.detoxrc.json` or run the command `detox init`.

nodejs-detox-test/e2e/config.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"maxWorkers": 1,
3+
"testEnvironment": "./environment",
4+
"testRunner": "jest-circus/runner",
5+
"testTimeout": 120000,
6+
"testRegex": "\\.e2e\\.js$",
7+
"reporters": ["detox/runners/jest/streamlineReporter"],
8+
"verbose": true
9+
}
Lines changed: 23 additions & 0 deletions
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;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
describe('Example', () => {
2+
beforeAll(async () => {
3+
await device.launchApp();
4+
});
5+
6+
beforeEach(async () => {
7+
await device.reloadReactNative();
8+
});
9+
10+
it('should have welcome screen', async () => {
11+
await expect(element(by.id('welcome'))).toBeVisible();
12+
});
13+
14+
it('should show hello screen after tap', async () => {
15+
await element(by.id('hello_button')).tap();
16+
await expect(element(by.text('Hello!!!'))).toBeVisible();
17+
});
18+
19+
it('should show world screen after tap', async () => {
20+
await element(by.id('world_button')).tap();
21+
await expect(element(by.text('World!!!'))).toBeVisible();
22+
});
23+
});

nodejs-detox-test/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "-y",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "ISC",
11+
"devDependencies": {
12+
"detox": "^19.4.2"
13+
}
14+
}

0 commit comments

Comments
 (0)