Skip to content

Commit 4e8aeca

Browse files
Update tests
1 parent 1138955 commit 4e8aeca

File tree

9 files changed

+157
-27
lines changed

9 files changed

+157
-27
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"android19": {
3+
"platformName": "Android",
4+
"platformVersion": "4.4",
5+
"deviceName": "Emulator-Api19-Default",
6+
"avd": "Emulator-Api19-Default",
7+
"lt": 60000,
8+
"appActivity": "com.tns.NativeScriptActivity",
9+
"newCommandTimeout": 720,
10+
"noReset": true,
11+
"fullReset": false,
12+
"app": ""
13+
},
14+
"android21": {
15+
"platformName": "Android",
16+
"platformVersion": "5.0",
17+
"deviceName": "Emulator-Api21-Default",
18+
"avd": "Emulator-Api21-Default",
19+
"lt": 60000,
20+
"appActivity": "com.tns.NativeScriptActivity",
21+
"newCommandTimeout": 720,
22+
"noReset": true,
23+
"fullReset": false,
24+
"app": ""
25+
},
26+
"android23": {
27+
"platformName": "Android",
28+
"platformVersion": "6.0",
29+
"deviceName": "Emulator-Api23-Default",
30+
"avd": "Emulator-Api23-Default",
31+
"lt": 60000,
32+
"appActivity": "com.tns.NativeScriptActivity",
33+
"newCommandTimeout": 720,
34+
"noReset": true,
35+
"fullReset": false,
36+
"app": ""
37+
},
38+
"android24": {
39+
"platformName": "Android",
40+
"platformVersion": "7.0",
41+
"deviceName": "Emulator-Api24-Default",
42+
"avd": "Emulator-Api24-Default",
43+
"lt": 60000,
44+
"appActivity": "com.tns.NativeScriptActivity",
45+
"newCommandTimeout": 720,
46+
"noReset": true,
47+
"fullReset": false,
48+
"app": ""
49+
},
50+
"android25": {
51+
"platformName": "Android",
52+
"platformVersion": "7.1",
53+
"deviceName": "Emulator-Api25-Google",
54+
"avd": "Emulator-Api25-Google",
55+
"lt": 60000,
56+
"appActivity": "com.tns.NativeScriptActivity",
57+
"newCommandTimeout": 720,
58+
"noReset": true,
59+
"fullReset": false,
60+
"app": ""
61+
},
62+
"android26": {
63+
"platformName": "Android",
64+
"platformVersion": "8.0",
65+
"deviceName": "Emulator-Api26-Google",
66+
"avd": "Emulator-Api26-Google",
67+
"lt": 60000,
68+
"appActivity": "com.tns.NativeScriptActivity",
69+
"newCommandTimeout": 720,
70+
"noReset": true,
71+
"fullReset": false,
72+
"app": ""
73+
},
74+
"sim.iPhone7.iOS100": {
75+
"platformName": "iOS",
76+
"platformVersion": "10.0",
77+
"deviceName": "iPhone 7 100",
78+
"noReset": true,
79+
"fullReset": false,
80+
"app": ""
81+
},
82+
"sim.iPhone7.iOS110": {
83+
"platformName": "iOS",
84+
"platformVersion": "11.0",
85+
"deviceName": "iPhone 7 110",
86+
"noReset": true,
87+
"fullReset": false,
88+
"app": ""
89+
}
90+
}

tests/e2e/config/mocha.opts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--timeout 80000
2+
--recursive e2e
3+
--reporter mocha-multi
4+
--reporter-options spec=-,mocha-junit-reporter=test-results.xml
File renamed without changes.

tests/e2e/setup.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { startServer, stopServer, createDriver, AppiumDriver } from "nativescript-dev-appium";
2+
3+
let driver: AppiumDriver;
4+
before("start server", async () => {
5+
await startServer();
6+
driver = await createDriver();
7+
});
8+
9+
afterEach(async function () {
10+
if (this.currentTest.state === "failed") {
11+
await driver.logScreenshot(this.currentTest.title);
12+
}
13+
});
14+
15+
after("stop server", async () => {
16+
await driver.quit();
17+
await stopServer();
18+
});
Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,44 @@
1-
"use strict";
2-
var nsAppium = require("nativescript-dev-appium");
1+
import { AppiumDriver, createDriver } from "nativescript-dev-appium";
2+
import { assert } from "chai";
33

44
describe("single page routing", function () {
55
this.timeout(360000);
6-
var driver;
6+
let driver: AppiumDriver;
77

8-
before(function () {
9-
driver = nsAppium.createDriver();
8+
before(async () => {
9+
driver = await createDriver();
1010
});
1111

12-
after(function () {
13-
return driver
14-
.quit()
15-
.finally(function () {
16-
console.log("Driver quit successfully");
17-
});
18-
});
19-
20-
it("loads default path", function () {
21-
return driver
22-
.waitForElementByAccessibilityId("first-single-page", 300000)
23-
.elementByAccessibilityId("first-single-page")
24-
.should.eventually.exist
25-
.text().should.eventually.equal("First: single-page")
12+
it("loads default path", async function () {
13+
const result = await driver.compareScreen("loadsDefaultPath", 1, 0.01);
14+
assert.isTrue(result);
2615
});
2716

28-
it("navigates and returns", function () {
17+
it("navigates and returns", async function () {
2918
var expectedHookLog = [
3019
"first.init", // <--load
3120
"first.destroy", // <--forward
3221
"second.init",
3322
"second.destroy", // <--back
3423
"first.init"].join(",");
3524

25+
await driver.click("first-single-page");
26+
3627
return driver
3728
.waitForElementByAccessibilityId("first-single-page", 300000)
3829
.elementByAccessibilityId("first-navigate-single-page")
39-
.should.eventually.exist
30+
.should.eventually.exist
4031
.tap()
4132
.elementByAccessibilityId("second-single-page")
42-
.should.eventually.exist
33+
.should.eventually.exist
4334
.text().should.eventually.equal("Second: single-page")
4435
.elementByAccessibilityId("second-navigate-back-single-page")
45-
.should.eventually.exist
36+
.should.eventually.exist
4637
.tap()
4738
.elementByAccessibilityId("first-single-page")
48-
.should.eventually.exist
39+
.should.eventually.exist
4940
.text().should.eventually.equal("First: single-page")
5041
.elementByAccessibilityId("hooks-log-single-page")
51-
.text().should.eventually.equal(expectedHookLog)
42+
.text().should.eventually.equal(expectedHookLog)
5243
});
5344
});

tests/e2e/tsconfig.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es5",
5+
"experimentalDecorators": true,
6+
"emitDecoratorMetadata": true,
7+
"importHelpers": true,
8+
"types": [
9+
"node",
10+
"mocha",
11+
"chai"
12+
],
13+
"lib": [
14+
"es6",
15+
"dom"
16+
]
17+
}
18+
}

tests/package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
"zone.js": "^0.8.2"
4343
},
4444
"devDependencies": {
45+
"@types/chai": "^4.0.2",
46+
"@types/mocha": "^2.2.41",
47+
"@types/node": "^7.0.5",
4548
"babel-traverse": "6.8.0",
4649
"babel-types": "6.8.1",
4750
"babylon": "6.8.0",
@@ -56,15 +59,20 @@
5659
"karma-nativescript-launcher": "^0.4.0",
5760
"lazy": "1.0.11",
5861
"mocha": "^2.4.5",
59-
"nativescript-dev-appium": "^0.4.0",
62+
"mocha-junit-reporter": "^1.13.0",
63+
"mocha-multi": "^0.11.0",
64+
"nativescript-dev-appium": "file:../../nativescript-dev-appium/nativescript-dev-appium-3.0.0.tgz",
6065
"nativescript-dev-typescript": "^0.4.0",
6166
"socket.io": "1.4.8",
6267
"socket.io-client": "1.4.8",
68+
"tslib": "^1.7.1",
6369
"tslint": "^4.5.1",
6470
"typescript": "~2.2.0",
6571
"wd": "^1.2.0"
6672
},
6773
"scripts": {
68-
"appium": "nativescript-dev-appium"
74+
"appium": "nativescript-dev-appium",
75+
"e2e": "tsc -p e2e && mocha --opts ./e2e/config/mocha.opts",
76+
"compile-tests": "tsc -p e2e --watch"
6977
}
7078
}

tests/references.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.d.ts" /> Needed for autocompletion and compilation.

0 commit comments

Comments
 (0)