Skip to content

Commit d690568

Browse files
vchimevvchimev
authored andcommitted
Add e2e tests
1 parent 97fd50b commit d690568

File tree

10 files changed

+1419
-29
lines changed

10 files changed

+1419
-29
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
hooks
12
node_modules
23
platforms
3-
hooks
44
report
55

66
app/**/*.js
7+
e2e/**/*.js
8+
e2e/**/*.map
9+
test-results.xml

app/home/home.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<StackLayout>
22
<Label text="Home Page" class="h1 text-center"></Label>
3-
4-
<Button [nsRouterLink]="'/support'" text="go to support"
3+
<Button [nsRouterLink]="'/support'" text="go to support page"
54
backgroundColor="hotpink"></Button>
65
</StackLayout>
76

app/support/support.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<StackLayout>
22
<Label text="Support Page" class="h1 text-center" ></Label>
3-
4-
<Button (tap)="router.back()" text="Go Back"></Button>
3+
<Button (tap)="router.back()" text="go back to home page"></Button>
54
</StackLayout>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"android19": {
3+
"browserName": "",
4+
"appium-version": "1.6.5",
5+
"platformName": "Android",
6+
"platformVersion": "4.4",
7+
"deviceName": "Emulator-Api19-Default",
8+
"avd": "Emulator-Api19-Default",
9+
"-lt": 60000,
10+
"automationName": "Appium",
11+
"appActivity": "com.tns.NativeScriptActivity",
12+
"newCommandTimeout": 720,
13+
"noReset": false,
14+
"fullReset": true,
15+
"app": ""
16+
},
17+
"android21": {
18+
"browserName": "",
19+
"appium-version": "1.6.5",
20+
"platformName": "Android",
21+
"platformVersion": "5.0",
22+
"deviceName": "Emulator-Api21-Default",
23+
"avd": "Emulator-Api21-Default",
24+
"-lt": 60000,
25+
"automationName": "Appium",
26+
"appActivity": "com.tns.NativeScriptActivity",
27+
"newCommandTimeout": 720,
28+
"noReset": false,
29+
"fullReset": true,
30+
"app": ""
31+
},
32+
"android23": {
33+
"browserName": "",
34+
"appium-version": "1.6.5",
35+
"platformName": "Android",
36+
"platformVersion": "6.0",
37+
"deviceName": "Emulator-Api23-Default",
38+
"avd": "Emulator-Api23-Default",
39+
"-lt": 60000,
40+
"automationName": "Appium",
41+
"appActivity": "com.tns.NativeScriptActivity",
42+
"newCommandTimeout": 720,
43+
"noReset": false,
44+
"fullReset": true,
45+
"app": ""
46+
},
47+
"android24": {
48+
"browserName": "",
49+
"appium-version": "1.6.5",
50+
"platformName": "Android",
51+
"platformVersion": "7.0",
52+
"deviceName": "Emulator-Api24-Default",
53+
"avd": "Emulator-Api24-Default",
54+
"-lt": 60000,
55+
"automationName": "UIAutomator2",
56+
"appActivity": "com.tns.NativeScriptActivity",
57+
"newCommandTimeout": 720,
58+
"noReset": false,
59+
"fullReset": true,
60+
"app": ""
61+
},
62+
"ios-simulator.iPhone7.ios10": {
63+
"browserName": "",
64+
"appium-version": "1.6.5",
65+
"platformName": "iOS",
66+
"platformVersion": "10.0",
67+
"deviceName": "iPhone 7 100",
68+
"noReset": true,
69+
"fullReset": false,
70+
"app": ""
71+
}
72+
}

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

e2e/sample-test.e2e.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const nsAppium = require("nativescript-dev-appium");
2+
3+
describe("sample scenario", () => {
4+
const defaultWaitTime = 5000;
5+
let driver;
6+
7+
before(async () => {
8+
driver = nsAppium.createDriver();
9+
});
10+
11+
after(async () => {
12+
await driver.quit();
13+
console.log("Quit driver!");
14+
});
15+
16+
it("should go to support page", async () => {
17+
const xPathBtnGoToSupportPage = nsAppium.getXPathWithExactText("go to support page");
18+
const btnGoToSupportPage = await driver.waitForElementByXPath(xPathBtnGoToSupportPage, defaultWaitTime);
19+
await btnGoToSupportPage.click();
20+
const titleSupportPage = await driver.waitForElementByXPath(nsAppium.getXPathContainingsText("Support Page"), defaultWaitTime);
21+
console.log(await titleSupportPage.text());
22+
});
23+
24+
it("should go back to home page", async () => {
25+
const xPathBtnGoBackToHomePage = nsAppium.getXPathWithExactText("go back to home page");
26+
const btnGoBackToHomePage = await driver.waitForElementByXPath(xPathBtnGoBackToHomePage, defaultWaitTime);
27+
await btnGoBackToHomePage.click();
28+
const titleHomePage = await driver.waitForElementByXPath(nsAppium.getXPathContainingsText("Home Page"), defaultWaitTime);
29+
console.log(await titleHomePage.text());
30+
});
31+
});

e2e/setup.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as setup from "nativescript-dev-appium";
2+
import * as portastic from "portastic";
3+
4+
before("setup server", async () => {
5+
console.log("Setting up server");
6+
const port = 9191;
7+
await setup.startAppiumServer(port);
8+
console.log("Server is started");
9+
});
10+
11+
before("setup driver", async () => {
12+
console.log("Setting up driver");
13+
});
14+
15+
after("kill driver", async () => {
16+
console.log("Kill driver");
17+
});
18+
19+
after("kill server", async () => {
20+
await setup.killAppiumServer();
21+
console.log("Server stopped");
22+
});

e2e/tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "../tsconfig",
3+
"compilerOptions": {
4+
"noEmitHelpers": false,
5+
"importHelpers": true,
6+
"noEmitOnError": true,
7+
"sourceMap": true,
8+
"types": [
9+
"node",
10+
"mocha",
11+
"chai"
12+
]
13+
}
14+
}

0 commit comments

Comments
 (0)