Skip to content

Commit 02d62f9

Browse files
Dimitar TodorovDimitar Todorov
authored andcommitted
Update dev appium and test reports
1 parent cb0c7db commit 02d62f9

File tree

6 files changed

+56
-5
lines changed

6 files changed

+56
-5
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
@@ -6,7 +6,9 @@ import {
66
import { isSauceLab, runType } from "nativescript-dev-appium/lib/parser";
77
import { expect } from "chai";
88
import "mocha";
9-
9+
const fs = require('fs');
10+
const addContext = require('mochawesome/addContext');
11+
const rimraf = require('rimraf');
1012
const isSauceRun = isSauceLab;
1113
const isAndroid: boolean = runType.includes("android");
1214

@@ -21,6 +23,11 @@ describe("Facebook tests", async function () {
2123
before(async () => {
2224
driver = await createDriver();
2325
driver.defaultWaitTime = 20000;
26+
let dir = "mochawesome-report";
27+
if (!fs.existsSync(dir)) {
28+
fs.mkdirSync(dir);
29+
}
30+
rimraf('mochawesome-report/*', function () { });
2431
});
2532

2633
after(async () => {
@@ -33,6 +40,19 @@ describe("Facebook tests", async function () {
3340
console.log("Driver successfully quit");
3441
});
3542

43+
afterEach(async function () {
44+
if (this.currentTest.state && this.currentTest.state === "failed") {
45+
let png = await driver.logScreenshot(this.currentTest.title);
46+
fs.copyFile(png, './mochawesome-report/' + this.currentTest.title + '.png', function (err) {
47+
if (err) {
48+
throw err;
49+
}
50+
console.log('Screenshot saved.');
51+
});
52+
addContext(this, './' + this.currentTest.title + '.png');
53+
}
54+
});
55+
3656
it("should log in via custom button", async function () {
3757
if (isAndroid) {
3858
var userNameLabelElement = "Nativescript User";

demo-vue/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@
2828
"chai-as-promised": "~7.1.1",
2929
"karma": "^2.0.2",
3030
"karma-nativescript-launcher": "^0.4.0",
31-
"mocha": "~5.2.0",
32-
"nativescript-dev-appium": "^4.0.9",
31+
"mocha": "^3.3.0",
32+
"mocha-junit-reporter": "^1.18.0",
33+
"mocha-multi": "^1.0.1",
34+
"mochawesome": "^3.1.1",
35+
"nativescript-dev-appium": "5.0.0",
3336
"nativescript-dev-typescript": "~0.8.0",
3437
"nativescript-dev-webpack": "~0.20.0",
3538
"nativescript-vue-template-compiler": "~2.0.2",

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
@@ -6,6 +6,9 @@ import {
66
import { isSauceLab, runType } from "nativescript-dev-appium/lib/parser";
77
import { expect } from "chai";
88
import "mocha";
9+
const fs = require('fs');
10+
const addContext = require('mochawesome/addContext');
11+
const rimraf = require('rimraf');
912

1013
const isSauceRun = isSauceLab;
1114
const isAndroid: boolean = runType.includes("android");
@@ -21,6 +24,11 @@ describe("Facebook tests", async function () {
2124
before(async () => {
2225
driver = await createDriver();
2326
driver.defaultWaitTime = 20000;
27+
let dir = "mochawesome-report";
28+
if (!fs.existsSync(dir)) {
29+
fs.mkdirSync(dir);
30+
}
31+
rimraf('mochawesome-report/*', function () { });
2432
});
2533

2634
after(async () => {
@@ -33,6 +41,19 @@ describe("Facebook tests", async function () {
3341
console.log("Driver successfully quit");
3442
});
3543

44+
afterEach(async function (){
45+
if (this.currentTest.state && this.currentTest.state === "failed") {
46+
let png = await driver.logScreenshot(this.currentTest.title);
47+
fs.copyFile(png, './mochawesome-report/' + this.currentTest.title + '.png', function (err) {
48+
if (err) {
49+
throw err;
50+
}
51+
console.log('Screenshot saved.');
52+
});
53+
addContext(this, './' + this.currentTest.title + '.png');
54+
}
55+
})
56+
3657
it("should log in via custom button", async function () {
3758
if (isAndroid) {
3859
var userNameLabelElement = "[@text='Nativescript User']";

demo/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
"karma": "^2.0.2",
2222
"karma-jasmine": "^1.1.2",
2323
"karma-nativescript-launcher": "^0.4.0",
24-
"mocha": "~5.2.0",
24+
"mocha": "^3.3.0",
25+
"mocha-junit-reporter": "^1.18.0",
26+
"mocha-multi": "^1.0.1",
27+
"mochawesome": "^3.1.1",
2528
"nativescript-css-loader": "~0.26.1",
26-
"nativescript-dev-appium": "4.0.9",
29+
"nativescript-dev-appium": "5.0.0",
2730
"nativescript-dev-typescript": "~0.8.0",
2831
"nativescript-dev-webpack": "~0.20.0",
2932
"tslint": "~5.11.0",

0 commit comments

Comments
 (0)