Skip to content

Commit 27dbb5d

Browse files
Merge pull request #252 from NativeScript/dtodorov/update-dev-appium
Update dev-appium and reports
2 parents 830161f + 8d18a2a commit 27dbb5d

File tree

6 files changed

+54
-3
lines changed

6 files changed

+54
-3
lines changed

demo-vue/e2e/config/mocha.opts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
--timeout 800000
22
--recursive e2e
3+
--reporter mocha-multi
4+
--reporter-options mochawesome=-,mocha-junit-reporter=test-results.xml
35
--exit

demo-vue/e2e/test.e2e.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium";
22
import { isSauceLab, runType } from "nativescript-dev-appium/lib/parser";
33
import { expect } from "chai";
4-
4+
const fs = require('fs');
5+
const addContext = require('mochawesome/addContext');
6+
const rimraf = require('rimraf');
57
const isSauceRun = isSauceLab;
68
const isAndroid: boolean = runType.includes("android");
79

@@ -14,6 +16,11 @@ describe("Imagepicker", async function () {
1416
before(async () => {
1517
driver = await createDriver();
1618
driver.defaultWaitTime = 10000;
19+
let dir = "mochawesome-report";
20+
if (!fs.existsSync(dir)) {
21+
fs.mkdirSync(dir);
22+
}
23+
rimraf('mochawesome-report/*', function () { });
1724
});
1825

1926
after(async () => {
@@ -26,6 +33,19 @@ describe("Imagepicker", async function () {
2633
console.log("Driver quits!");
2734
});
2835

36+
afterEach(async function () {
37+
if (this.currentTest.state && this.currentTest.state === "failed") {
38+
let png = await driver.logScreenshot(this.currentTest.title);
39+
fs.copyFile(png, './mochawesome-report/' + this.currentTest.title + '.png', function (err) {
40+
if (err) {
41+
throw err;
42+
}
43+
console.log('Screenshot saved.');
44+
});
45+
addContext(this, './' + this.currentTest.title + '.png');
46+
}
47+
});
48+
2949
it("should pick one image", async function () {
3050
// await driver.driver.resetApp();
3151
const pickSingleButtonText = "Pick Single";

demo-vue/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
"babel-loader": "~8.0.0",
2424
"chai": "~4.1.2",
2525
"chai-as-promised": "~7.1.1",
26-
"mocha": "~5.2.0",
26+
"mocha": "^3.3.0",
27+
"mocha-junit-reporter": "^1.18.0",
28+
"mocha-multi": "^1.0.1",
29+
"mochawesome": "^3.1.1",
2730
"nativescript-dev-appium": "^4.0.9",
2831
"nativescript-dev-webpack": "~0.20.0",
2932
"nativescript-dev-typescript": "~0.8.0",

demo/e2e/config/mocha.opts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
--timeout 800000
22
--recursive e2e
3+
--reporter mocha-multi
4+
--reporter-options mochawesome=-,mocha-junit-reporter=test-results.xml
35
--exit

demo/e2e/test.e2e.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium";
22
import { isSauceLab, runType } from "nativescript-dev-appium/lib/parser";
33
import { expect } from "chai";
4+
const fs = require('fs');
5+
const addContext = require('mochawesome/addContext');
6+
const rimraf = require('rimraf');
47

58
const isSauceRun = isSauceLab;
69
const isAndroid: boolean = runType.includes("android");
@@ -14,6 +17,11 @@ describe("Imagepicker", async function () {
1417
before(async () => {
1518
driver = await createDriver();
1619
driver.defaultWaitTime = 10000;
20+
let dir = "mochawesome-report";
21+
if (!fs.existsSync(dir)) {
22+
fs.mkdirSync(dir);
23+
}
24+
rimraf('mochawesome-report/*', function () { });
1725
});
1826

1927
after(async () => {
@@ -26,6 +34,19 @@ describe("Imagepicker", async function () {
2634
console.log("Driver quits!");
2735
});
2836

37+
afterEach(async function () {
38+
if (this.currentTest.state && this.currentTest.state === "failed") {
39+
let png = await driver.logScreenshot(this.currentTest.title);
40+
fs.copyFile(png, './mochawesome-report/' + this.currentTest.title + '.png', function (err) {
41+
if (err) {
42+
throw err;
43+
}
44+
console.log('Screenshot saved.');
45+
});
46+
addContext(this, './' + this.currentTest.title + '.png');
47+
}
48+
});
49+
2950
it("should pick one image", async function () {
3051
// await driver.driver.resetApp();
3152
const pickSingleButtonText = "Pick Single";

demo/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
"karma": "^2.0.5",
2525
"karma-jasmine": "^1.1.2",
2626
"karma-nativescript-launcher": "^0.4.0",
27-
"mocha": "~5.2.0",
27+
"mocha": "^3.3.0",
28+
"mocha-junit-reporter": "^1.18.0",
29+
"mocha-multi": "^1.0.1",
30+
"mochawesome": "^3.1.1",
2831
"nativescript-css-loader": "~0.26.0",
2932
"nativescript-dev-appium": "4.0.9",
3033
"nativescript-dev-typescript": "~0.8.0",

0 commit comments

Comments
 (0)