Browse Source

Added detox init

Jamon Holmgren 6 years ago
parent
commit
bd11e54131
4 changed files with 45 additions and 0 deletions
  1. 4
    0
      WebTest/e2e/config.json
  2. 19
    0
      WebTest/e2e/firstTest.spec.js
  3. 19
    0
      WebTest/e2e/init.js
  4. 3
    0
      WebTest/package.json

+ 4
- 0
WebTest/e2e/config.json View File

@@ -0,0 +1,4 @@
1
+{
2
+    "setupTestFrameworkScriptFile": "./init.js",
3
+    "testEnvironment": "node"
4
+}

+ 19
- 0
WebTest/e2e/firstTest.spec.js View File

@@ -0,0 +1,19 @@
1
+describe('Example', () => {
2
+  beforeEach(async () => {
3
+    await device.reloadReactNative();
4
+  });
5
+
6
+  it('should have welcome screen', async () => {
7
+    await expect(element(by.id('welcome'))).toBeVisible();
8
+  });
9
+
10
+  it('should show hello screen after tap', async () => {
11
+    await element(by.id('hello_button')).tap();
12
+    await expect(element(by.text('Hello!!!'))).toBeVisible();
13
+  });
14
+
15
+  it('should show world screen after tap', async () => {
16
+    await element(by.id('world_button')).tap();
17
+    await expect(element(by.text('World!!!'))).toBeVisible();
18
+  });
19
+})

+ 19
- 0
WebTest/e2e/init.js View File

@@ -0,0 +1,19 @@
1
+const detox = require('detox');
2
+const config = require('../package.json').detox;
3
+const adapter = require('detox/runners/jest/adapter');
4
+
5
+jest.setTimeout(120000);
6
+jasmine.getEnv().addReporter(adapter);
7
+
8
+beforeAll(async () => {
9
+  await detox.init(config);
10
+});
11
+
12
+beforeEach(async () => {
13
+  await adapter.beforeEach();
14
+});
15
+
16
+afterAll(async () => {
17
+  await adapter.afterAll();
18
+  await detox.cleanup();
19
+});

+ 3
- 0
WebTest/package.json View File

@@ -18,5 +18,8 @@
18 18
   },
19 19
   "jest": {
20 20
     "preset": "react-native"
21
+  },
22
+  "detox": {
23
+    "test-runner": "jest"
21 24
   }
22 25
 }