Skip to content

Commit

Permalink
tests: implement mochawesome reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
SvetoslavTsenov committed May 7, 2019
1 parent c3f4661 commit 6babbd7
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 76 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ e2e/reports
verify-report
e2e/**/*.js
e2e/reports
app/App_Resources/iOS/GoogleService-Info.plist
app/App_Resources/iOS/GoogleService-Info.plist
mochawesome-report
108 changes: 105 additions & 3 deletions e2e/config/appium.capabilities.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,122 @@
{
"android19": {
"platformName": "Android",
"platformVersion": "4.4",
"deviceName": "Emulator-Api19-Default",
"avd": "Emulator-Api19-Default",
"lt": 60000,
"newCommandTimeout": 720,
"noReset": false,
"fullReset": false,
"app": ""
},
"android21": {
"platformName": "Android",
"platformVersion": "5.0",
"deviceName": "Emulator-Api21-Default",
"avd": "Emulator-Api21-Default",
"lt": 60000,
"newCommandTimeout": 720,
"noReset": false,
"fullReset": false,
"app": ""
},
"android23": {
"platformName": "Android",
"platformVersion": "6.0",
"deviceName": "Emulator-Api23-Default",
"avd": "Emulator-Api23-Default",
"lt": 60000,
"newCommandTimeout": 720,
"noReset": false,
"fullReset": false,
"app": ""
},
"android24": {
"platformName": "Android",
"platformVersion": "7.0",
"deviceName": "Emulator-Api24-Default",
"avd": "Emulator-Api24-Default",
"lt": 60000,
"newCommandTimeout": 720,
"noReset": false,
"fullReset": false,
"app": ""
},
"android25": {
"platformName": "Android",
"platformVersion": "7.1",
"deviceName": "Emulator-Api25-Google",
"avd": "Emulator-Api25-Google",
"lt": 60000,
"newCommandTimeout": 720,
"noReset": false,
"fullReset": false,
"app": ""
},
"android26": {
"platformName": "Android",
"platformVersion": "8.0",
"deviceName": "Emulator-Api26-Google",
"avd": "Emulator-Api26-Google",
"lt": 60000,
"newCommandTimeout": 720,
"noReset": false,
"fullReset": false,
"app": ""
},
"android27": {
"platformName": "Android",
"platformVersion": "27",
"deviceName": "Emulator-Api27-Google",
"avd": "Emulator-Api27-Google",
"lt": 60000,
"newCommandTimeout": 720,
"noReset": false,
"fullReset": false,
"app": ""
},
"android28": {
"platformName": "Android",
"platformVersion": "28",
"deviceName": "Emulator-Api28-Google",
"avd": "Emulator-Api28-Google",
"lt": 60000,
"newCommandTimeout": 720,
"noReset": false,
"fullReset": false,
"app": ""
},
"sim.iPhoneXS": {
"sim.iPhone7": {
"platformName": "iOS",
"platformVersion": "/12.*/",
"deviceName": "iPhone 7",
"noReset": false,
"fullReset": false,
"app": ""
},
"sim.iPhone8": {
"platformName": "iOS",
"platformVersion": "/12*/",
"deviceName": "iPhone 8",
"noReset": false,
"fullReset": false,
"app": ""
},
"sim.iPhoneX": {
"platformName": "iOS",
"platformVersion": "12.0",
"platformVersion": "/12*/",
"deviceName": "iPhone X",
"noReset": false,
"fullReset": false,
"app": ""
},
"sim.iPhoneXS": {
"platformName": "ios",
"platformVersion": "/12*/",
"deviceName": "iPhone XS",
"noReset": false,
"fullReset": false,
"app": ""
}
}
}
4 changes: 2 additions & 2 deletions e2e/config/mocha.opts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--timeout 999999
--recursive e2e
--reporter mocha-multi
--reporter-options spec=-,mocha-junit-reporter=test-results.xml
--reporter mochawesome
--reporter-options quiet=true,html=true,inline=true,autoOpen=true
--exit
24 changes: 12 additions & 12 deletions e2e/sample.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { AppiumDriver, createDriver, SearchOptions, Point } from "nativescript-dev-appium";
import { AppiumDriver, createDriver, SearchOptions, Point, nsCapabilities } from "nativescript-dev-appium";
import { assert } from "chai";

describe("sample scenario", () => {
const defaultWaitTime = 5000;
describe("sample scenario", async function () {
let driver: AppiumDriver;
let sideDrawerBtnRect: Point;

before(async () => {
before(async function () {
nsCapabilities.testReporter.context = this;
driver = await createDriver();
});

after(async () => {
after(async function () {
await driver.quit();
console.log("Quit driver!");
});
Expand All @@ -21,7 +21,7 @@ describe("sample scenario", () => {
}
});

const openSidedrawer = async () => {
const openSidedrawer = async function () {
if (driver.isAndroid) {
if (!sideDrawerBtnRect) {
const btnSideDrawer = await driver.findElementByText("COSMOS Databank");
Expand All @@ -46,7 +46,7 @@ describe("sample scenario", () => {
}
}

const closeSidedrawer = async () => {
const closeSidedrawer = async function () {
if (driver.isAndroid) {
await driver.clickPoint(sideDrawerBtnRect.x, sideDrawerBtnRect.y);
} else {
Expand All @@ -62,7 +62,7 @@ describe("sample scenario", () => {
}
}

it("no pass login", async () => {
it("no pass login", async function () {
const allowCameraBtn = (await driver.findElementByTextIfExists("Allow"))
if (allowCameraBtn) {
await allowCameraBtn.click();
Expand All @@ -74,23 +74,23 @@ describe("sample scenario", () => {
assert.isTrue(astronomicalDayElement != null && (await astronomicalDayElement.isDisplayed()));
});

it("open sidedrawer menu", async () => {
it("open sidedrawer menu", async function () {
await openSidedrawer();
const showSideDrawerResult = await driver.compareScreen("side-drawer-displayed", 5, 0.01);
assert.isTrue(showSideDrawerResult);
});

it("close sidedrawer menu", async () => {
it("close sidedrawer menu", async function () {
await closeSidedrawer();
const showSideDrawerResult = await driver.compareScreen("side-drawer-closed", 5, 0.01);
assert.isTrue(showSideDrawerResult);
});

it("navigate to photo of the day and back", async () => {
it("navigate to photo of the day and back", async function () {
await openSidedrawer();
await driver.sleep(5000);

const navToPhotoOfTheDay = async () => {
const navToPhotoOfTheDay = async function () {
if (driver.isAndroid) {
(await driver.findElementByText("Photo of the day")).click();
} else {
Expand Down
15 changes: 12 additions & 3 deletions e2e/setup.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { startServer, stopServer } from "nativescript-dev-appium";
import { startServer, stopServer, ITestReporter, nsCapabilities, LogImageType } from "nativescript-dev-appium";
const addContext = require('mochawesome/addContext');

before("start server", async () => {
const testReporterContext = <ITestReporter>{};
testReporterContext.name = "mochawesome";
testReporterContext.reportDir = "mochawesome-report";
testReporterContext.log = addContext;
testReporterContext.logImageTypes = [LogImageType.screenshots];
nsCapabilities.testReporter = testReporterContext;

before("start server", async function () {
nsCapabilities.testReporter.context = this;
await startServer();
});

after("stop server", async () => {
after("stop server", async function () {
await stopServer();
});
109 changes: 54 additions & 55 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,56 @@
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.curiosity"
},
"dependencies": {
"@angular/animations": "~7.2.0",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/http": "~7.2.0",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"nativescript-angular": "next",
"nativescript-app-center": "^1.0.3",
"nativescript-cardview": "^3.1.1",
"nativescript-permissions": "^1.3.5",
"nativescript-plugin-firebase": "^8.2.0",
"nativescript-social-share": "^1.5.1",
"nativescript-theme-core": "^1.0.4",
"nativescript-ui-sidedrawer": "^6.0.0",
"reflect-metadata": "~0.1.13",
"rxjs": "^6.3.3",
"tns-core-modules": "next",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/compiler-cli": "~7.2.0",
"@ngtools/webpack": "~7.2.0",
"@types/chai": "~4.1.3",
"@types/mocha": "~5.2.1",
"@types/node": "10.11.4",
"codelyzer": "^4.4.4",
"mocha": "~5.1.0",
"mocha-junit-reporter": "~1.17.0",
"mocha-multi": "~1.0.0",
"nativescript-dev-appium": "^5.1.0",
"nativescript-dev-typescript": "next",
"nativescript-dev-webpack": "next",
"tns-platform-declarations": "~5.3.1",
"tslint": "^5.11.0",
"typescript": "~3.1.1"
},
"scripts": {
"tslint": "tslint -p tsconfig.json",
"e2e": "node ./node_modules/nativescript-dev-appium/check-dev-deps.js && tsc -p e2e && mocha --opts ./e2e/config/mocha.opts ",
"e2e-watch": "tsc -p e2e --watch",
"update-app-ng-deps": "update-app-ng-deps",
"ns-verify-bundle": "ns-verify-bundle",
"update-ns-webpack": "update-ns-webpack"
}
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.curiosity"
},
"dependencies": {
"@angular/animations": "~7.2.0",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/http": "~7.2.0",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"nativescript-angular": "next",
"nativescript-app-center": "^1.0.3",
"nativescript-cardview": "^3.1.1",
"nativescript-permissions": "^1.3.5",
"nativescript-plugin-firebase": "^8.2.0",
"nativescript-social-share": "^1.5.1",
"nativescript-theme-core": "^1.0.4",
"nativescript-ui-sidedrawer": "^6.0.0",
"reflect-metadata": "~0.1.13",
"rxjs": "^6.3.3",
"tns-core-modules": "next",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/compiler-cli": "~7.2.0",
"@ngtools/webpack": "~7.2.0",
"@types/chai": "~4.1.7",
"@types/mocha": "~5.2.5",
"@types/node": "~10.12.18",
"codelyzer": "^4.4.4",
"mocha": "~5.2.0",
"mochawesome": "~3.1.2",
"nativescript-dev-appium": "^next",
"nativescript-dev-typescript": "next",
"nativescript-dev-webpack": "next",
"tns-platform-declarations": "~5.3.1",
"tslint": "^5.11.0",
"typescript": "~3.1.1"
},
"scripts": {
"tslint": "tslint -p tsconfig.json",
"e2e": "node ./node_modules/nativescript-dev-appium/check-dev-deps.js && tsc -p e2e && mocha --opts ./e2e/config/mocha.opts ",
"e2e-watch": "tsc -p e2e --watch",
"update-app-ng-deps": "update-app-ng-deps",
"ns-verify-bundle": "ns-verify-bundle",
"update-ns-webpack": "update-ns-webpack"
}
}

0 comments on commit 6babbd7

Please sign in to comment.