Skip to content

Commit 6f10dad

Browse files
Merge pull request #174 from NativeScript/dtodorov/update-dev-appium
Update dev-appium and test reports
2 parents 0e320c1 + 0d1ffad commit 6f10dad

File tree

6 files changed

+44
-14
lines changed

6 files changed

+44
-14
lines changed

demo-vue/e2e/config/mocha.opts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
--timeout 800000
22
--recursive e2e
33
--reporter mocha-multi
4-
--reporter-options spec=-,mocha-junit-reporter=test-results.xml
4+
--reporter-options mochawesome=-,mocha-junit-reporter=test-results.xml

demo-vue/e2e/tests.e2e.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { AppiumDriver, createDriver, SearchOptions, Direction, UIElement, Point,
22
import { isSauceLab, runType } from "nativescript-dev-appium/lib/parser";
33
import { expect } from "chai";
44
import { exec } from "child_process";
5-
5+
const fs = require('fs');
6+
const addContext = require('mochawesome/addContext');
7+
const rimraf = require('rimraf');
68
const isSauceRun = isSauceLab;
79
const isAndroid: boolean = runType.includes("android");
810

@@ -12,6 +14,11 @@ describe("Camera", () => {
1214
before(async () => {
1315
driver = await createDriver();
1416
driver.defaultWaitTime = 15000;
17+
let dir = "mochawesome-report";
18+
if (!fs.existsSync(dir)) {
19+
fs.mkdirSync(dir);
20+
}
21+
rimraf('mochawesome-report/*', function () { });
1522
});
1623

1724
after(async () => {
@@ -25,8 +32,15 @@ describe("Camera", () => {
2532
});
2633

2734
afterEach(async function () {
28-
if (this.currentTest.state === "failed") {
29-
await driver.logScreenshot(this.currentTest.title);
35+
if (this.currentTest.state && this.currentTest.state === "failed") {
36+
let png = await driver.logScreenshot(this.currentTest.title);
37+
fs.copyFile(png, './mochawesome-report/' + this.currentTest.title + '.png', function (err) {
38+
if (err) {
39+
throw err;
40+
}
41+
console.log('Screenshot saved.');
42+
});
43+
addContext(this, './' + this.currentTest.title + '.png');
3044
}
3145
});
3246

demo-vue/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
"@types/mocha": "~5.2.5",
2626
"@types/node": "~10.12.18",
2727
"babel-loader": "~8.0.0",
28-
"mocha": "~5.2.0",
29-
"mocha-junit-reporter": "~1.18.0",
30-
"mocha-multi": "~1.0.1",
28+
"mocha": "^3.3.0",
29+
"mocha-junit-reporter": "^1.18.0",
30+
"mocha-multi": "^1.0.1",
31+
"mochawesome": "^3.1.1",
3132
"nativescript-dev-appium": "4.0.9",
3233
"nativescript-dev-typescript": "~0.8.0",
3334
"nativescript-dev-webpack": "~0.20.0",

demo/e2e/config/mocha.opts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
--timeout 800000
22
--recursive e2e
33
--reporter mocha-multi
4-
--reporter-options spec=-,mocha-junit-reporter=test-results.xml
4+
--reporter-options mochawesome=-,mocha-junit-reporter=test-results.xml

demo/e2e/tests.e2e.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { AppiumDriver, createDriver, SearchOptions, Direction, UIElement, Point, Locator } 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

@@ -11,6 +13,11 @@ describe("Camera", () => {
1113
before(async () => {
1214
driver = await createDriver();
1315
driver.defaultWaitTime = 15000;
16+
let dir = "mochawesome-report";
17+
if (!fs.existsSync(dir)) {
18+
fs.mkdirSync(dir);
19+
}
20+
rimraf('mochawesome-report/*', function () { });
1421
});
1522

1623
after(async () => {
@@ -24,8 +31,15 @@ describe("Camera", () => {
2431
});
2532

2633
afterEach(async function () {
27-
if (this.currentTest.state === "failed") {
28-
await driver.logScreenshot(this.currentTest.title);
34+
if (this.currentTest.state && this.currentTest.state === "failed") {
35+
let png = await driver.logScreenshot(this.currentTest.title);
36+
fs.copyFile(png, './mochawesome-report/' + this.currentTest.title + '.png', function (err) {
37+
if (err) {
38+
throw err;
39+
}
40+
console.log('Screenshot saved.');
41+
});
42+
addContext(this, './' + this.currentTest.title + '.png');
2943
}
3044
});
3145

demo/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
"@types/chai": "~4.1.7",
3030
"@types/mocha": "~5.2.5",
3131
"@types/node": "~10.12.18",
32-
"mocha": "~5.2.0",
33-
"mocha-junit-reporter": "~1.18.0",
34-
"mocha-multi": "~1.0.1",
32+
"mocha": "^3.3.0",
33+
"mocha-junit-reporter": "^1.18.0",
34+
"mocha-multi": "^1.0.1",
35+
"mochawesome": "^3.1.1",
3536
"nativescript-css-loader": "~0.26.1",
3637
"nativescript-dev-appium": "4.0.9",
3738
"nativescript-dev-typescript": "~0.8.0",

0 commit comments

Comments
 (0)