From d4ad5fec9104c32066242e3abcea495198588a2c Mon Sep 17 00:00:00 2001 From: Fatme Date: Thu, 18 Apr 2019 17:04:15 +0300 Subject: [PATCH 1/6] release: cut the 0.21.1 release (#869) --- CHANGELOG.md | 13 +++++++++++++ package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c52998fa..5af59993 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ + +## [0.21.1](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.21.0...0.21.1) (2019-04-18) + + +### Bug Fixes + +* add support for ts files on test command when `--bundle` is provided ([#848](https://github.com/NativeScript/nativescript-dev-webpack/issues/848)) ([bd4fa9c](https://github.com/NativeScript/nativescript-dev-webpack/commit/bd4fa9c)) +* fix "ERROR in Must have a source file to refactor." error from ngCompilerPlugin on `test` command ([#859](https://github.com/NativeScript/nativescript-dev-webpack/issues/859)) ([196d977](https://github.com/NativeScript/nativescript-dev-webpack/commit/196d977)) +* typescript source maps are containing javascript code ([#857](https://github.com/NativeScript/nativescript-dev-webpack/issues/857)) ([384bee2](https://github.com/NativeScript/nativescript-dev-webpack/commit/384bee2)) +* use correct slashes on windows ([#851](https://github.com/NativeScript/nativescript-dev-webpack/issues/851)) ([9020c47](https://github.com/NativeScript/nativescript-dev-webpack/commit/9020c47)) + + + # [0.21.0](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.20.3...0.21.0) (2019-03-21) diff --git a/package.json b/package.json index 695e365d..6a0a709d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-dev-webpack", - "version": "0.21.0", + "version": "0.21.1", "main": "index", "description": "", "homepage": "http://www.telerik.com", From c8afe9fcef4698eabe474a2ed6faac80039ae7f9 Mon Sep 17 00:00:00 2001 From: Fatme Date: Fri, 19 Apr 2019 12:19:37 +0300 Subject: [PATCH 2/6] fix: add support for executing unit tests for vue projects (#839) (#870) --- templates/webpack.vue.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/templates/webpack.vue.js b/templates/webpack.vue.js index 3ed688de..3361cc3d 100644 --- a/templates/webpack.vue.js +++ b/templates/webpack.vue.js @@ -253,6 +253,21 @@ module.exports = env => { ], }; + if (unitTesting) { + config.module.rules.push( + { + test: /-page\.js$/, + use: "nativescript-dev-webpack/script-hot-loader" + }, + { + test: /\.(html|xml)$/, + use: "nativescript-dev-webpack/markup-hot-loader" + }, + + { test: /\.(html|xml)$/, use: "nativescript-dev-webpack/xml-namespace-loader"} + ); + } + // Copy the native app resources to the out dir // only if doing a full build (tns run/build) and not previewing (tns preview) if (!externals || externals.length === 0) { From ff226b2389b8d4697d77862b0804425e9e82f4df Mon Sep 17 00:00:00 2001 From: Fatme Date: Tue, 23 Apr 2019 09:34:52 +0300 Subject: [PATCH 3/6] release: cut the 0.21.2 release (#871) --- CHANGELOG.md | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5af59993..845a7224 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +## [0.21.2](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.21.0...0.21.2) (2019-04-22) + + +### Bug Fixes + +* add support for executing unit tests for vue projects ([#870](https://github.com/NativeScript/nativescript-dev-webpack/issues/870)) ([c8afe9f](https://github.com/NativeScript/nativescript-dev-webpack/commit/c8afe9f)) + + + ## [0.21.1](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.21.0...0.21.1) (2019-04-18) diff --git a/package.json b/package.json index 6a0a709d..cf938de4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-dev-webpack", - "version": "0.21.1", + "version": "0.21.2", "main": "index", "description": "", "homepage": "http://www.telerik.com", From be82ab7a267d6c8a0ab879fe289115eeae73f8f0 Mon Sep 17 00:00:00 2001 From: DimitarTachev Date: Tue, 23 Apr 2019 11:20:34 +0300 Subject: [PATCH 4/6] fix: ignore the Webpack runtime chunks when sending HMR updates --- lib/compiler.js | 2 +- lib/utils.js | 6 +++++- plugins/WatchStateLoggerPlugin.ts | 24 +++++++++++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index 588edc5d..6398436c 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -80,7 +80,7 @@ exports.runWebpackCompiler = function runWebpackCompiler(config, $projectData, $ return; } - const result = getUpdatedEmittedFiles(message.emittedFiles); + const result = getUpdatedEmittedFiles(message.emittedFiles, message.webpackRuntimeFiles); if (hookArgs.hmrData) { hookArgs.hmrData[platform] = { diff --git a/lib/utils.js b/lib/utils.js index 5bb0dea2..b5341c52 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -34,7 +34,7 @@ function buildEnvData($projectData, platform, env) { * if yes this is a HMR update and remove all bundle files as we don't need them to be synced, * but only the update chunks */ -function getUpdatedEmittedFiles(emittedFiles) { +function getUpdatedEmittedFiles(emittedFiles, webpackRuntimeFiles) { let fallbackFiles = []; let hotHash; if (emittedFiles.some(x => x.endsWith('.hot-update.json'))) { @@ -45,6 +45,10 @@ function getUpdatedEmittedFiles(emittedFiles) { hotHash = hash; // remove bundle/vendor.js files if there's a bundle.XXX.hot-update.js or vendor.XXX.hot-update.js result = result.filter(file => file !== `${name}.js`); + if (webpackRuntimeFiles && webpackRuntimeFiles.length) { + // remove files containing only the Webpack runtime (e.g. runtime.js) + result = result.filter(file => webpackRuntimeFiles.indexOf(file) === -1); + } }); //if applying of hot update fails, we must fallback to the full files fallbackFiles = emittedFiles.filter(file => result.indexOf(file) === -1); diff --git a/plugins/WatchStateLoggerPlugin.ts b/plugins/WatchStateLoggerPlugin.ts index 565407c1..0a8229c5 100644 --- a/plugins/WatchStateLoggerPlugin.ts +++ b/plugins/WatchStateLoggerPlugin.ts @@ -31,6 +31,7 @@ export class WatchStateLoggerPlugin { console.log(messages.compilationComplete); } + const runtimeOnlyFiles = getWebpackRuntimeOnlyFiles(compilation, compiler); let emittedFiles = Object .keys(compilation.assets) .filter(assetKey => compilation.assets[assetKey].emitted); @@ -42,7 +43,28 @@ export class WatchStateLoggerPlugin { process.send && process.send(messages.compilationComplete, error => null); // Send emitted files so they can be LiveSynced if need be - process.send && process.send({ emittedFiles: emittedFilesFakePaths }, error => null); + process.send && process.send({ emittedFiles: emittedFilesFakePaths, webpackRuntimeFiles: runtimeOnlyFiles }, error => null); }); } } + +function getWebpackRuntimeOnlyFiles(compilation, compiler) { + let runtimeOnlyFiles = []; + try { + runtimeOnlyFiles = [].concat(...compilation.chunkGroups + // get the chunk group of each entry points (e.g. main.js and inspector-modules.js) + .map(chunkGroup => chunkGroup.runtimeChunk) + // filter embedded runtime chunks (e.g. part of bundle.js or inspector-modules.js) + .filter(runtimeChunk => runtimeChunk.preventIntegration) + .map(runtimeChunk => runtimeChunk.files)) + // get only the unique files in case of "single" runtime (e.g. runtime.js) + .filter((value, index, self) => self.indexOf(value) === index) + // convert to absolute paths + .map(fileName => join(compiler.context, fileName)); + } catch (e) { + // breaking change in the Webpack API + console.log("Warning: Unable to find Webpack runtime files."); + } + + return runtimeOnlyFiles; +} From e9b52b64be37d6eaa4c6a5c375a5d438596ef1e9 Mon Sep 17 00:00:00 2001 From: Stanimira Vlaeva Date: Thu, 25 Apr 2019 09:00:22 +0300 Subject: [PATCH 5/6] chore: apply PR suggestions --- plugins/WatchStateLoggerPlugin.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/WatchStateLoggerPlugin.ts b/plugins/WatchStateLoggerPlugin.ts index 0a8229c5..55cbb8ba 100644 --- a/plugins/WatchStateLoggerPlugin.ts +++ b/plugins/WatchStateLoggerPlugin.ts @@ -31,7 +31,7 @@ export class WatchStateLoggerPlugin { console.log(messages.compilationComplete); } - const runtimeOnlyFiles = getWebpackRuntimeOnlyFiles(compilation, compiler); + const runtimeOnlyFiles = getWebpackRuntimeOnlyFiles(compilation, compiler.context); let emittedFiles = Object .keys(compilation.assets) .filter(assetKey => compilation.assets[assetKey].emitted); @@ -48,19 +48,18 @@ export class WatchStateLoggerPlugin { } } -function getWebpackRuntimeOnlyFiles(compilation, compiler) { +function getWebpackRuntimeOnlyFiles(compilation, basePath) { let runtimeOnlyFiles = []; try { - runtimeOnlyFiles = [].concat(...compilation.chunkGroups - // get the chunk group of each entry points (e.g. main.js and inspector-modules.js) - .map(chunkGroup => chunkGroup.runtimeChunk) + runtimeOnlyFiles = [].concat(...Array.from(compilation.entrypoints.values()) + .map(entrypoint => entrypoint.runtimeChunk) // filter embedded runtime chunks (e.g. part of bundle.js or inspector-modules.js) - .filter(runtimeChunk => runtimeChunk.preventIntegration) + .filter(runtimeChunk => !!runtimeChunk && runtimeChunk.preventIntegration) .map(runtimeChunk => runtimeChunk.files)) // get only the unique files in case of "single" runtime (e.g. runtime.js) .filter((value, index, self) => self.indexOf(value) === index) // convert to absolute paths - .map(fileName => join(compiler.context, fileName)); + .map(fileName => join(basePath, fileName)); } catch (e) { // breaking change in the Webpack API console.log("Warning: Unable to find Webpack runtime files."); From 300de7d47ef1d3f27f0121714f3239c8a19b3ec1 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Wed, 8 May 2019 12:29:52 +0200 Subject: [PATCH 6/6] tests: use mochawesome reporter (#881) * tests: use mochawesome reporter --- demo/AngularApp/.gitignore | 3 +- demo/AngularApp/app/activity.android.ts | 2 +- demo/AngularApp/e2e/setup.ts | 15 ++- demo/AngularApp/e2e/tests.e2e-spec.ts | 13 +- demo/AngularApp/e2e/tsconfig.json | 8 +- demo/AngularApp/package.json | 32 +++-- demo/JavaScriptApp/.gitignore | 3 +- .../e2e/config/appium.capabilities.json | 74 ++++++----- demo/JavaScriptApp/e2e/setup.js | 37 +++--- demo/JavaScriptApp/e2e/tests.e2e-spec.js | 117 ++++++++---------- demo/JavaScriptApp/package.json | 7 +- demo/TypeScriptApp/e2e/config/mocha.opts | 5 + demo/TypeScriptApp/e2e/setup.ts | 15 ++- demo/TypeScriptApp/e2e/tests.e2e-spec.ts | 13 +- demo/TypeScriptApp/package.json | 7 +- demo/config/appium.capabilities.json | 37 +++--- demo/config/mocha.opts | 5 +- 17 files changed, 211 insertions(+), 182 deletions(-) create mode 100644 demo/TypeScriptApp/e2e/config/mocha.opts diff --git a/demo/AngularApp/.gitignore b/demo/AngularApp/.gitignore index f84eb8e5..1ccc6d9f 100644 --- a/demo/AngularApp/.gitignore +++ b/demo/AngularApp/.gitignore @@ -9,4 +9,5 @@ e2e/reports/ test-results.xml app/item/items.component.android.css -app/item/items.component.ios.css \ No newline at end of file +app/item/items.component.ios.css +mochawesome-report \ No newline at end of file diff --git a/demo/AngularApp/app/activity.android.ts b/demo/AngularApp/app/activity.android.ts index f10f9307..7b86ae14 100644 --- a/demo/AngularApp/app/activity.android.ts +++ b/demo/AngularApp/app/activity.android.ts @@ -1,4 +1,4 @@ -import {setActivityCallbacks, AndroidActivityCallbacks} from "ui/frame"; +import {setActivityCallbacks, AndroidActivityCallbacks} from "tns-core-modules/ui/frame"; @JavaProxy("org.myApp.MainActivity") class Activity extends android.support.v7.app.AppCompatActivity { diff --git a/demo/AngularApp/e2e/setup.ts b/demo/AngularApp/e2e/setup.ts index 8b26e66e..cd73140b 100644 --- a/demo/AngularApp/e2e/setup.ts +++ b/demo/AngularApp/e2e/setup.ts @@ -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 = {}; +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(); }); diff --git a/demo/AngularApp/e2e/tests.e2e-spec.ts b/demo/AngularApp/e2e/tests.e2e-spec.ts index 80a5e51e..47e67d10 100644 --- a/demo/AngularApp/e2e/tests.e2e-spec.ts +++ b/demo/AngularApp/e2e/tests.e2e-spec.ts @@ -1,10 +1,10 @@ import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium"; import { assert } from "chai"; -describe("sample scenario", () => { +describe("sample scenario", async function () { let driver: AppiumDriver; - before(async () => { + before(async function () { driver = await createDriver(); }); @@ -26,17 +26,16 @@ describe("sample scenario", () => { afterEach(async function () { if (this.currentTest.state === "failed") { - await driver.logPageSource(this.currentTest.title); - await driver.logScreenshot(this.currentTest.title); + await driver.logTestArtifacts(this.currentTest.title); } }); - after(async () => { + after(async function () { await driver.quit(); console.log("Quit driver!"); }); - it("should navigate to a ninja", async () => { + it("should navigate to a ninja", async function () { const btnNinjas = await driver.findElementByText("Ninjas"); await btnNinjas.click(); @@ -67,5 +66,5 @@ describe("sample scenario", () => { }); } - const getItems = async () => { return driver.isAndroid ? await driver.findElementsByText("(Android)") : await driver.findElementsByText("(ios)"); } + const getItems = async function () { return driver.isAndroid ? await driver.findElementsByText("(Android)") : await driver.findElementsByText("(ios)"); } }); diff --git a/demo/AngularApp/e2e/tsconfig.json b/demo/AngularApp/e2e/tsconfig.json index 6517ca58..abb4a3a7 100644 --- a/demo/AngularApp/e2e/tsconfig.json +++ b/demo/AngularApp/e2e/tsconfig.json @@ -5,15 +5,15 @@ "experimentalDecorators": true, "emitDecoratorMetadata": true, "importHelpers": false, - "sourceMap": true, "types": [ - "node", "mocha", - "chai" + "chai", + "node" ], "lib": [ "es2015", "dom" - ] + ], + "baseUrl": "." } } \ No newline at end of file diff --git a/demo/AngularApp/package.json b/demo/AngularApp/package.json index a5bfb550..9319f154 100644 --- a/demo/AngularApp/package.json +++ b/demo/AngularApp/package.json @@ -13,36 +13,34 @@ } }, "dependencies": { - "@angular/common": "~7.1.0", - "@angular/compiler": "~7.1.0", - "@angular/core": "~7.1.0", - "@angular/forms": "~7.1.0", - "@angular/http": "~7.1.0", - "@angular/platform-browser": "~7.1.0", - "@angular/platform-browser-dynamic": "~7.1.0", - "@angular/router": "~7.1.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-theme-core": "~1.0.2", "reflect-metadata": "~0.1.8", - "rxjs": "~6.3.3", + "rxjs": "^6.3.3", "tns-core-modules": "next", - "zone.js": "~0.8.26" + "zone.js": "^0.8.4" }, "devDependencies": { - "@angular/compiler-cli": "~7.1.0", - "@ngtools/webpack": "~7.1.2", + "@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.12", + "@types/node": "~10.12.18", "babel-traverse": "6.26.0", "babel-types": "6.26.0", "babylon": "6.18.0", - "chai": "~4.1.1", "chai-as-promised": "~7.1.1", "lazy": "1.0.11", "mocha": "~5.2.0", - "mocha-junit-reporter": "~1.18.0", - "mocha-multi": "~1.0.1", + "mochawesome": "~3.1.2", "nativescript-dev-appium": "next", "nativescript-dev-sass": "next", "nativescript-dev-typescript": "next", @@ -54,4 +52,4 @@ "e2e": "tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json", "compile-tests": "tsc -p e2e --watch" } -} \ No newline at end of file +} diff --git a/demo/JavaScriptApp/.gitignore b/demo/JavaScriptApp/.gitignore index e4b64c6a..c457995c 100644 --- a/demo/JavaScriptApp/.gitignore +++ b/demo/JavaScriptApp/.gitignore @@ -1,2 +1,3 @@ app/main-page.android.css -app/main-page.ios.css \ No newline at end of file +app/main-page.ios.css +mochawesome-report \ No newline at end of file diff --git a/demo/JavaScriptApp/e2e/config/appium.capabilities.json b/demo/JavaScriptApp/e2e/config/appium.capabilities.json index 3cd2bab2..b4c9be76 100644 --- a/demo/JavaScriptApp/e2e/config/appium.capabilities.json +++ b/demo/JavaScriptApp/e2e/config/appium.capabilities.json @@ -5,9 +5,8 @@ "deviceName": "Emulator-Api19-Default", "avd": "Emulator-Api19-Default", "lt": 60000, - "appActivity": "com.tns.NativeScriptActivity", "newCommandTimeout": 720, - "noReset": true, + "noReset": false, "fullReset": false, "app": "" }, @@ -17,9 +16,8 @@ "deviceName": "Emulator-Api21-Default", "avd": "Emulator-Api21-Default", "lt": 60000, - "appActivity": "com.tns.NativeScriptActivity", "newCommandTimeout": 720, - "noReset": true, + "noReset": false, "fullReset": false, "app": "" }, @@ -29,9 +27,8 @@ "deviceName": "Emulator-Api23-Default", "avd": "Emulator-Api23-Default", "lt": 60000, - "appActivity": "com.tns.NativeScriptActivity", "newCommandTimeout": 720, - "noReset": true, + "noReset": false, "fullReset": false, "app": "" }, @@ -41,9 +38,8 @@ "deviceName": "Emulator-Api24-Default", "avd": "Emulator-Api24-Default", "lt": 60000, - "appActivity": "com.tns.NativeScriptActivity", "newCommandTimeout": 720, - "noReset": true, + "noReset": false, "fullReset": false, "app": "" }, @@ -53,9 +49,8 @@ "deviceName": "Emulator-Api25-Google", "avd": "Emulator-Api25-Google", "lt": 60000, - "appActivity": "com.tns.NativeScriptActivity", "newCommandTimeout": 720, - "noReset": true, + "noReset": false, "fullReset": false, "app": "" }, @@ -65,42 +60,63 @@ "deviceName": "Emulator-Api26-Google", "avd": "Emulator-Api26-Google", "lt": 60000, - "appActivity": "com.tns.NativeScriptActivity", "newCommandTimeout": 720, - "noReset": true, + "noReset": false, "fullReset": false, "app": "" }, - "sim.iPhone7.iOS100": { - "platformName": "iOS", - "platformVersion": "10.0", - "deviceName": "iPhone 7 100", - "noReset": true, + "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.iPhone8.iOS110": { + "sim.iPhone7": { "platformName": "iOS", - "platformVersion": "11.2", - "deviceName": "iPhone 8 110", - "noReset": true, + "platformVersion": "/12.*/", + "deviceName": "iPhone 7", + "noReset": false, "fullReset": false, "app": "" }, - "sim.iPhoneX.iOS110": { + "sim.iPhone8": { "platformName": "iOS", - "platformVersion": "11.2", - "deviceName": "iPhone X", - "noReset": true, + "platformVersion": "/12*/", + "deviceName": "iPhone 8", + "noReset": false, "fullReset": false, "app": "" }, - "sim.iPhoneX.iOS111": { + "sim.iPhoneX": { "platformName": "iOS", - "platformVersion": "11.1", + "platformVersion": "/12*/", "deviceName": "iPhone X", - "noReset": true, + "noReset": false, + "fullReset": false, + "app": "" + }, + "sim.iPhoneXS": { + "platformName": "ios", + "platformVersion": "/12*/", + "deviceName": "iPhone XS", + "noReset": false, "fullReset": false, "app": "" } -} +} \ No newline at end of file diff --git a/demo/JavaScriptApp/e2e/setup.js b/demo/JavaScriptApp/e2e/setup.js index 0809e972..1161c87b 100644 --- a/demo/JavaScriptApp/e2e/setup.js +++ b/demo/JavaScriptApp/e2e/setup.js @@ -1,18 +1,19 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const nativescript_dev_appium_1 = require("nativescript-dev-appium"); -before("start server", () => __awaiter(this, void 0, void 0, function* () { - yield nativescript_dev_appium_1.startServer(); -})); -after("stop server", () => __awaiter(this, void 0, void 0, function* () { - yield nativescript_dev_appium_1.stopServer(); -})); -//# sourceMappingURL=setup.js.map \ No newline at end of file +const nsAppium = require("nativescript-dev-appium"); +const addContext = require('mochawesome/addContext'); + +const testReporterContext = {}; +testReporterContext.name = "mochawesome"; +testReporterContext.reportDir = "mochawesome-report"; +testReporterContext.log = addContext; +testReporterContext.logImageTypes = [nsAppium.LogImageType.screenshots]; +nsAppium.nsCapabilities.testReporter = testReporterContext; + +before("start server", async function () { + nsAppium.nsCapabilities.testReporter.context = this; + await nsAppium.startServer(); +}); + +after("stop appium server", async function () { + nsAppium.nsCapabilities.testReporter.context = this; + await nsAppium.stopServer(); +}); diff --git a/demo/JavaScriptApp/e2e/tests.e2e-spec.js b/demo/JavaScriptApp/e2e/tests.e2e-spec.js index 169ca81c..bd889360 100644 --- a/demo/JavaScriptApp/e2e/tests.e2e-spec.js +++ b/demo/JavaScriptApp/e2e/tests.e2e-spec.js @@ -1,77 +1,64 @@ "use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const nativescript_dev_appium_1 = require("nativescript-dev-appium"); -const chai_1 = require("chai"); -describe("sample scenario", () => { +const nsAppium = require("nativescript-dev-appium"); +const chai = require("chai"); + +describe("sample scenario", function () { let driver; - before(() => __awaiter(this, void 0, void 0, function* () { - driver = yield nativescript_dev_appium_1.createDriver(); + before((async function () { + nsAppium.nsCapabilities.testReporter.context = this; + driver = await nsAppium.createDriver(); })); - beforeEach(function () { - return __awaiter(this, void 0, void 0, function* () { - try { - const lblPlatform = yield getPlatformLabel(); - } - catch (err) { - console.log("Navigating to main page ..."); - yield driver.navBack(); - } - }); + + beforeEach(async function () { + try { + const lblPlatform = await getPlatformLabel(); + } + catch (err) { + console.log("Navigating to main page ..."); + await driver.navBack(); + } }); - afterEach(function () { - return __awaiter(this, void 0, void 0, function* () { - if (this.currentTest.state === "failed") { - yield driver.logPageSource(this.currentTest.title); - yield driver.logScreenshot(this.currentTest.title); - } - }); + + afterEach(async function () { + if (this.currentTest.state === "failed") { + await driver.logTestArtifacts(this.currentTest.title); + } }); - after(() => __awaiter(this, void 0, void 0, function* () { - yield driver.quit(); - console.log("Quit driver!"); - })); - it("should the button on second page work", () => __awaiter(this, void 0, void 0, function* () { - const btnNav = yield driver.findElementByText("btnNav"); - yield btnNav.tap(); - const secondPage = yield driver.findElementByText("Second Page"); - const btnZero = yield driver.findElementByText("0"); - yield btnZero.tap(); - // In iOS, the `automationText` property applies on both `name` and `label`: - // https://github.com/NativeScript/NativeScript/issues/3150 - // - // - const btnOne = yield driver.findElementByText("1"); - yield driver.navBack(); - })); - it("should the button on main page work", () => __awaiter(this, void 0, void 0, function* () { - const btnTap = yield driver.findElementByText("TAP"); - yield btnTap.tap(); - const lblTaps = yield driver.findElementByText("taps left", 1 /* contains */); - const lblTapsText = yield lblTaps.text(); - chai_1.assert.isTrue(lblTapsText.includes("41")); - })); + + it("should the button on second page work", async function () { + const btnNav = await driver.findElementByText("btnNav"); + await btnNav.tap(); + const secondPage = await driver.findElementByText("Second Page"); + const btnZero = await driver.findElementByText("0"); + await btnZero.tap(); + const btnOne = await driver.findElementByText("1"); + await driver.navBack(); + }); + + it("should the button on main page work", async function () { + const btnTap = await driver.findElementByText("TAP"); + await btnTap.tap(); + const lblTaps = await driver.findElementByText("taps left", 1 /* contains */); + const lblTapsText = await lblTaps.text(); + chai.assert.isTrue(lblTapsText.includes("41")); + }); + const styleTypes = { "inline": "styleInline", "page": "stylePage", "app": "styleApp" }; - for (let styleType in styleTypes) { - it(`should find an element with ${styleType} style applied`, function () { - return __awaiter(this, void 0, void 0, function* () { - const element = yield driver.findElementByText(styleTypes[styleType]); - const result = yield driver.compareElement(element, "style"); - chai_1.assert.isTrue(result); - }); + for (let index = 0; index < styleTypes.length; index++) { + const styleType = array[index]; + + it(`should find an element with ${styleType} style applied`, async function () { + const element = await driver.findElementByText(styleTypes[styleType]); + const result = await driver.compareElement(element, "style"); + chai.assert.isTrue(result); }); } - const getPlatformLabel = () => __awaiter(this, void 0, void 0, function* () { return driver.isAndroid ? yield driver.findElementByText("android") : yield driver.findElementByText("ios"); }); -}); -//# sourceMappingURL=tests.e2e-spec.js.map \ No newline at end of file + + const getPlatformLabel = async function() { + return driver.isAndroid ? await driver.findElementByText("android") : await driver.findElementByText("ios"); + } +}); \ No newline at end of file diff --git a/demo/JavaScriptApp/package.json b/demo/JavaScriptApp/package.json index ee3eb6e2..4118a33c 100644 --- a/demo/JavaScriptApp/package.json +++ b/demo/JavaScriptApp/package.json @@ -19,14 +19,13 @@ "devDependencies": { "@types/chai": "~4.1.7", "@types/mocha": "~5.2.5", - "@types/node": "~10.12.12", + "@types/node": "~10.12.18", "babel-traverse": "6.26.0", "babel-types": "6.26.0", "babylon": "6.18.0", "lazy": "1.0.11", "mocha": "~5.2.0", - "mocha-junit-reporter":"~1.18.0", - "mocha-multi":"~1.0.1", + "mochawesome": "~3.1.2", "nativescript-dev-appium": "next", "nativescript-dev-sass": "next", "nativescript-dev-webpack": "next", @@ -36,4 +35,4 @@ "setup": "npm pack ../../ && npm i -D nativescript-dev-webpack*.tgz", "e2e": "mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json" } -} \ No newline at end of file +} diff --git a/demo/TypeScriptApp/e2e/config/mocha.opts b/demo/TypeScriptApp/e2e/config/mocha.opts new file mode 100644 index 00000000..c21dcca6 --- /dev/null +++ b/demo/TypeScriptApp/e2e/config/mocha.opts @@ -0,0 +1,5 @@ +--timeout 999999 +--recursive e2e +--reporter mochawesome +--reporter-options quiet=true,html=true,inline=true,autoOpen=true +--exit \ No newline at end of file diff --git a/demo/TypeScriptApp/e2e/setup.ts b/demo/TypeScriptApp/e2e/setup.ts index 8b26e66e..cd73140b 100644 --- a/demo/TypeScriptApp/e2e/setup.ts +++ b/demo/TypeScriptApp/e2e/setup.ts @@ -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 = {}; +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(); }); diff --git a/demo/TypeScriptApp/e2e/tests.e2e-spec.ts b/demo/TypeScriptApp/e2e/tests.e2e-spec.ts index ed4c5e80..37920f3c 100644 --- a/demo/TypeScriptApp/e2e/tests.e2e-spec.ts +++ b/demo/TypeScriptApp/e2e/tests.e2e-spec.ts @@ -1,10 +1,11 @@ -import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium"; +import { AppiumDriver, createDriver, SearchOptions, nsCapabilities } from "nativescript-dev-appium"; import { assert } from "chai"; describe("sample scenario", () => { let driver: AppiumDriver; - before(async () => { + before(async function () { + nsCapabilities.testReporter.context = this; driver = await createDriver(); }); @@ -24,12 +25,12 @@ describe("sample scenario", () => { } }); - after(async () => { + after(async function () { await driver.quit(); console.log("Quit driver!"); }); - it("should the button on second page work", async () => { + it("should the button on second page work", async function () { const btnNav = await driver.findElementByText("btnNav"); await btnNav.tap(); @@ -45,7 +46,7 @@ describe("sample scenario", () => { await driver.navBack(); }); - it("should the button on main page work", async () => { + it("should the button on main page work", async function () { const btnTap = await driver.findElementByText("TAP"); await btnTap.tap(); @@ -68,5 +69,5 @@ describe("sample scenario", () => { }); } - const getPlatformLabel = async () => { return driver.isAndroid ? await driver.findElementByText("android") : await driver.findElementByText("ios"); } + const getPlatformLabel = async function () { return driver.isAndroid ? await driver.findElementByText("android") : await driver.findElementByText("ios"); } }); \ No newline at end of file diff --git a/demo/TypeScriptApp/package.json b/demo/TypeScriptApp/package.json index babf8489..62c8f58c 100644 --- a/demo/TypeScriptApp/package.json +++ b/demo/TypeScriptApp/package.json @@ -19,14 +19,13 @@ "devDependencies": { "@types/chai": "~4.1.7", "@types/mocha": "~5.2.5", - "@types/node": "~10.12.12", + "@types/node": "~10.12.18", "babel-traverse": "6.26.0", "babel-types": "6.26.0", "babylon": "6.18.0", "lazy": "1.0.11", "mocha": "~5.2.0", - "mocha-junit-reporter": "~1.18.0", - "mocha-multi": "~1.0.1", + "mochawesome": "~3.1.2", "nativescript-dev-appium": "next", "nativescript-dev-sass": "next", "nativescript-dev-typescript": "next", @@ -38,4 +37,4 @@ "e2e": "tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json", "compile-tests": "tsc -p e2e --watch" } -} \ No newline at end of file +} diff --git a/demo/config/appium.capabilities.json b/demo/config/appium.capabilities.json index af7d5e3e..b4c9be76 100644 --- a/demo/config/appium.capabilities.json +++ b/demo/config/appium.capabilities.json @@ -76,42 +76,45 @@ "fullReset": false, "app": "" }, - "sim.iPhone7.iOS100": { - "platformName": "iOS", - "platformVersion": "10.0", - "deviceName": "iPhone 7 100", + "android28": { + "platformName": "Android", + "platformVersion": "28", + "deviceName": "Emulator-Api28-Google", + "avd": "Emulator-Api28-Google", + "lt": 60000, + "newCommandTimeout": 720, "noReset": false, "fullReset": false, "app": "" }, - "sim.iPhone7.iOS110": { + "sim.iPhone7": { "platformName": "iOS", - "platformVersion": "11.2", - "deviceName": "iPhone 7 110", + "platformVersion": "/12.*/", + "deviceName": "iPhone 7", "noReset": false, "fullReset": false, "app": "" }, - "sim.iPhone8.iOS110": { + "sim.iPhone8": { "platformName": "iOS", - "platformVersion": "11.2", - "deviceName": "iPhone 8 110", + "platformVersion": "/12*/", + "deviceName": "iPhone 8", "noReset": false, "fullReset": false, "app": "" }, - "sim.iPhoneX.iOS110": { + "sim.iPhoneX": { "platformName": "iOS", - "platformVersion": "11.2", - "deviceName": "iPhone X 110", + "platformVersion": "/12*/", + "deviceName": "iPhone X", "noReset": false, "fullReset": false, "app": "" }, - "sim.iPhoneX.iOS111": { - "platformName": "iOS", - "platformVersion": "11.1", - "deviceName": "iPhone X 111", + "sim.iPhoneXS": { + "platformName": "ios", + "platformVersion": "/12*/", + "deviceName": "iPhone XS", "noReset": false, "fullReset": false, "app": "" diff --git a/demo/config/mocha.opts b/demo/config/mocha.opts index 796ec472..8e77e681 100644 --- a/demo/config/mocha.opts +++ b/demo/config/mocha.opts @@ -1,4 +1,5 @@ --timeout 80000 --recursive e2e ---reporter mocha-multi ---reporter-options spec=-,mocha-junit-reporter=test-results.xml \ No newline at end of file +--reporter mochawesome +--reporter-options quiet=true,html=true,inline=true,autoOpen=true +--exit \ No newline at end of file