diff --git a/.gitignore b/.gitignore
index 610c9ed25..9399b9cd3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,7 @@ ng-sample/app/**/*.js
# Webpack configuration files
webpack.config.js
tsconfig.esm.json
+tsconfig.tns.json
# IDEs and editors
/.idea
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3a955ef1f..bba452911 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,18 @@
+## [7.2.4](https://github.com/NativeScript/nativescript-angular/compare/7.2.3...7.2.4) (2019-04-24)
+
+
+### Bug Fixes
+
+* **router:** routing services should be provided in forRoot only ([#1729](https://github.com/NativeScript/nativescript-angular/issues/1729)) ([0f6a975](https://github.com/NativeScript/nativescript-angular/commit/0f6a975))
+* ngOnDestroy not called on Android back button ([#923](https://github.com/NativeScript/nativescript-angular/issues/923))
+
+
+### Features
+
+* **modal:** add ‘ios presentationStyle’ option to ModalDialogParams ([9cfa127](https://github.com/NativeScript/nativescript-angular/commit/9cfa127))
+
+
+
## [7.2.3](https://github.com/NativeScript/nativescript-angular/compare/7.2.2...7.2.3) (2019-03-14)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 13889f11d..b42d49f3b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -81,36 +81,105 @@ If you want to contribute, but you are not sure where to start - look for [issue
## Publishing new versions
-Instructions how to publish a new version for Maintainers.
-1. Execute `npm install` to install dependencies and prepare the package for publishing:
-```bash
-cd nativescript-angular/nativescript-angular
-npm install
+## Releasing new versions
+Instructions how to release a new version for **NativeScript Core Team Members**.
+
+
+
+1. Checkout release branch
+```
+cd nativescript-angular/nativescript-angular && git checkout release && git pull
+```
+#### If we prepare major or minor release, merge master in release branch else **skip this step**.
```
+git merge --ff-only origin/master
+```
+*** Note: If there are commits in release branch which are not merged in master branch '-ff-merge' command will fail.
+In this case the commits should be merge firstly from release in master branch as explained in section 'Merge changes from release into master' and then repeat step 1.
-2. Add the following to your `.npmrc`:
+2. Execute `npm i` to install dependencies:
+```
+cd nativescript-angular && npm i
+```
+3. Execute [`npm version`](https://docs.npmjs.com/cli/version) to bump the version:
+```
+npm --no-git-tag-version version [patch|minor|major] -m "release: cut the %s release"
+```
+or
```
-tag-version-prefix=""
-message="release: cut the %s release"
+npm --no-git-tag-version version [version] --allow-same-version -m "release: cut the %s release"
```
+NOTE: Check the changelog!!!
-3. Create new branch for the release:
-```bash
-git checkout -b username/release-version
+4. Create release-branch with change log
+```
+git checkout -b release-[version]
+```
+5. Add changes
```
+git add changed-files
+git commit -m "release: cut the %s release"
+git push
+```
+NOTE: Make sure the PR is based on release branch
-4. Execute [`npm version`](https://docs.npmjs.com/cli/version) to bump the version in the `package.json` file, tag the release and update the CHANGELOG.md:
-```bash
-npm version [patch|minor|major]
+6. Merge PR into release branch.
+
+7. The merge will produce package with rc tag in npm. If all checks have passed, publish official package. Usually the night builds will be triggered and the package will be ready to be released on the next day.
+
+8. Don't forget to tag the release branch
+```
+git tag [version]
+git push --tags
+```
+Only if needed to Tips to remove tags:
+```
+git push --delete origin [version]
+git tag -d [version]
```
-5. Push all the changes to your branch and create a pull request:
-```bash
-git push --set-upstream origin username/release-version --tags
+## Checkout master branch and bump version usually should be minor or major.
+
+## Merge changes from release into master
+
+## NOTE: Don't use git IDE/WEB
+
+
+
+### Here are steps described in the diagram above.
+
+1. Make sure you are in release branch:
+```
+git checkout release && git pull
+```
+2. Create PR to merge changes back in master and preserve history:
```
+git checkout -b merge-release-in-master-[branch]/[sha]
+git push --set-upstream origin merge-release-in-master-branch-[branch]/[sha]
+git merge origin/master
+```
+3. Resolve conflicts. Choose to keep the version of master branch. If it is needed to revert versions of modules, see at the bottom.
-6. Publish the package to `npm` after the pull request is merged:
-```bash
-npm publish
+4. Add conflicts:
+```
+git add resolved files
+```
+5. Commit changes with default merge message:
+```
+git commit
+git push
+```
+
+6. Create pull request which should be based on master. Replace replace env merge-release-in-master-branch with its value
+```
+curl -d '{"title": "chore: merge release in master","body": "chore: merge release in master","head": "merge-release-in-master","base": "master"}' -X POST https://api.github.com/repos/NativeScript/NativeScript/pulls -H "Authorization: token ${GIT_TOKEN}"
+```
+
+**If needed, to revert file and take it from master:**
+```
+git checkout origin/master nativescript-angular/[some-file]
+git commit --amend
+git push --force-with-lease
```
+This could require to repeat steps from 1 to 4, since we need to keep the branches with the same history
diff --git a/build-docs.sh b/build-docs.sh
new file mode 100755
index 000000000..a0f39ec85
--- /dev/null
+++ b/build-docs.sh
@@ -0,0 +1,9 @@
+set -e
+
+ENV="${ENV:-dev}"
+DIST_DIR="nativescript-angular/bin/dist"
+APIREF_DIR="$DIST_DIR/ng-api-reference"
+rm -rf "$APIREF_DIR"
+cd "nativescript-angular"
+npm install
+npm run typedoc
diff --git a/e2e/config/mocha.opts b/e2e/config/mocha.opts
index ea635b0dc..719c7e05a 100644
--- a/e2e/config/mocha.opts
+++ b/e2e/config/mocha.opts
@@ -1,4 +1,5 @@
---timeout 140000
+--timeout 60000
--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
diff --git a/e2e/modal-navigation-ng/.gitignore b/e2e/modal-navigation-ng/.gitignore
index 06947f093..23d2d7b1d 100644
--- a/e2e/modal-navigation-ng/.gitignore
+++ b/e2e/modal-navigation-ng/.gitignore
@@ -6,3 +6,4 @@ app/**/*.js
e2e/**/*.js
e2e/reports
test-results.xml
+mochawesome-report
diff --git a/e2e/modal-navigation-ng/app/navigation/basic.navigation.component.ts b/e2e/modal-navigation-ng/app/navigation/basic.navigation.component.ts
index 54c818612..49f7a2567 100644
--- a/e2e/modal-navigation-ng/app/navigation/basic.navigation.component.ts
+++ b/e2e/modal-navigation-ng/app/navigation/basic.navigation.component.ts
@@ -1,4 +1,4 @@
-import { Component, ViewContainerRef, Input } from "@angular/core";
+import { Component, ViewContainerRef, Input, ViewChild, ElementRef } from "@angular/core";
import { Router, NavigationEnd } from "@angular/router";
import { ModalDialogService, ModalDialogOptions } from "nativescript-angular/directives/dialogs";
import { ModalComponent } from "../modal/modal.component";
@@ -16,12 +16,14 @@ import { ModalViewComponent } from "~/modal-shared/modal-view.component";
+
`
})
export class BasicsNavigationComponent {
+ @ViewChild("popoverButtonComp") popoverButtonComp: ElementRef;
@Input() col: number;
constructor(
private modal: ModalDialogService,
@@ -29,7 +31,7 @@ export class BasicsNavigationComponent {
private vcf: ViewContainerRef,
private viewContainerRefService: ViewContainerRefService) {
}
-
+
onModalNoFrame() {
const options: ModalDialogOptions = {
context: {
@@ -74,14 +76,28 @@ export class BasicsNavigationComponent {
onRootModalTap(): void {
const options: ModalDialogOptions = {
- viewContainerRef: this.viewContainerRefService.root,
- context: {},
- fullscreen: true
+ viewContainerRef: this.viewContainerRefService.root,
+ context: {},
+ fullscreen: true
};
-
+
this.modal.showModal(ModalViewComponent, options)
- .then((result: string) => {
- console.log(result);
- });
- }
+ .then((result: string) => {
+ console.log(result);
+ });
+ }
+
+ onPopoverModal() {
+ const options: ModalDialogOptions = {
+ viewContainerRef: this.viewContainerRefService.root,
+ context: {},
+ ios: {
+ presentationStyle: UIModalPresentationStyle.Popover
+ },
+ target: this.popoverButtonComp.nativeElement
+ };
+
+ this.modal.showModal(ModalViewComponent, options)
+ .then((result: string) => { console.log(result);});
+ }
}
diff --git a/e2e/modal-navigation-ng/e2e/modal-frame.e2e-spec.ts b/e2e/modal-navigation-ng/e2e/modal-frame.e2e-spec.ts
index d5de6c2bb..ff58c3843 100644
--- a/e2e/modal-navigation-ng/e2e/modal-frame.e2e-spec.ts
+++ b/e2e/modal-navigation-ng/e2e/modal-frame.e2e-spec.ts
@@ -1,4 +1,4 @@
-import { AppiumDriver, createDriver } from "nativescript-dev-appium";
+import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium";
import { Screen } from "./screens/screen"
import {
roots,
@@ -10,20 +10,23 @@ import {
testDialogBackground
} from "./screens/shared-screen"
-describe("modal-frame:", () => {
+describe("modal-frame:", async function () {
let driver: AppiumDriver;
let screen: Screen;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
screen = new Screen(driver);
});
- roots.forEach(root => {
- describe(`${root} modal frame background scenarios:`, () => {
+ for (let index = 0; index < roots.length; index++) {
+ const root = roots[index];
+ describe(`${root} modal frame background scenarios:`, async function () {
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
await screen[root]();
});
@@ -38,45 +41,45 @@ describe("modal-frame:", () => {
}
});
- after(async () => {
+ after(async function () {
await screen.closeModal();
await screen.loadedHome();
});
- it("should show dialog confirm, run in background", async () => {
+ it("should show dialog confirm, run in background", async function () {
await screen.loadModalFrame(true);
await testDialogBackground(driver, screen);
});
- it("should run modal page with frame in background", async () => {
+ it("should run modal page with frame in background", async function () {
await screen.loadModalFrame(false);
await modalFrameBackground(driver, screen);
});
- it("should navigate to second page, run in background, go back", async () => {
+ it("should navigate to second page, run in background, go back", async function () {
await screen.loadModalFrame(false);
await testSecondPageBackground(driver, screen);
});
- it("should show nested modal page with frame, run in background, close", async () => {
+ it("should show nested modal page with frame, run in background, close", async function () {
await screen.loadModalFrame(false);
await testNestedModalFrameBackground(driver, screen);
});
- it("should show nested modal page, run in background, close", async () => {
+ it("should show nested modal page, run in background, close", async function () {
await screen.loadModalFrame(false);
await testNestedModalPageBackground(driver, screen);
});
- it("should navigate to second page, close", async () => {
+ it("should navigate to second page, close", async function () {
await screen.loadModalFrame(false);
await testSecondPageClose(driver, screen);
});
- it("should navigate to second page, run in background, go back", async () => {
+ it("should navigate to second page, run in background, go back", async function () {
await screen.loadModalFrame(true);
await testSecondPageBackground(driver, screen);
});
});
- });
+ };
});
diff --git a/e2e/modal-navigation-ng/e2e/modal-layout.e2e-spec.ts b/e2e/modal-navigation-ng/e2e/modal-layout.e2e-spec.ts
index b518f1a95..1cdcdf333 100644
--- a/e2e/modal-navigation-ng/e2e/modal-layout.e2e-spec.ts
+++ b/e2e/modal-navigation-ng/e2e/modal-layout.e2e-spec.ts
@@ -1,4 +1,4 @@
-import { AppiumDriver, createDriver } from "nativescript-dev-appium";
+import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium";
import { Screen } from "./screens/screen"
import {
roots,
@@ -6,19 +6,20 @@ import {
testDialogBackground,
} from "./screens/shared-screen"
-describe("modal-layout:", () => {
-
+describe("modal-layout:", async function () {
let driver: AppiumDriver;
let screen: Screen;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
screen = new Screen(driver);
});
-
- roots.forEach(root => {
- describe(`${root} modal no frame background scenarios:`, () => {
- before(async () => {
+ for (let index = 0; index < roots.length; index++) {
+ const root = roots[index];
+ describe(`${root} modal no frame background scenarios:`, async function () {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
await screen[root]();
});
@@ -30,21 +31,21 @@ describe("modal-layout:", () => {
}
});
- after(async () => {
+ after(async function () {
await screen.closeModal();
await screen.loadedHome();
});
- it("should show nested modal page, run in background, close", async () => {
+ it("should show nested modal page, run in background, close", async function () {
await screen.loadModalNoFrame(true);
await testNestedModalPageBackground(driver, screen, false);
});
- it("should show dialog confirm inside modal view with no frame, run in background", async () => {
+ it("should show dialog confirm inside modal view with no frame, run in background", async function () {
await screen.loadModalNoFrame(false);
await testDialogBackground(driver, screen, false);
});
});
- });
+ };
});
diff --git a/e2e/modal-navigation-ng/e2e/modal-on-init.e2e-spec.ts b/e2e/modal-navigation-ng/e2e/modal-on-init.e2e-spec.ts
index 394fa5d49..34f682b77 100644
--- a/e2e/modal-navigation-ng/e2e/modal-on-init.e2e-spec.ts
+++ b/e2e/modal-navigation-ng/e2e/modal-on-init.e2e-spec.ts
@@ -1,4 +1,4 @@
-import { AppiumDriver, createDriver } from "nativescript-dev-appium";
+import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium";
import { Screen, sharedModalView, homeComponent } from "./screens/screen";
import {
assertComponent,
@@ -12,29 +12,33 @@ const roots = [
"setNamedFrameRootViewModal",
];
-describe("modal-on-init:", () => {
+describe("modal-on-init:", async function () {
let driver: AppiumDriver;
let screen: Screen;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
+
driver = await createDriver();
screen = new Screen(driver);
});
- after("modal-on-init after all hook", async () => {
+ after("modal-on-init after all hook", async function () {
await driver.logTestArtifacts("modal-on-init");
});
- roots.forEach(root => {
- describe("Shared Modal on Init", () => {
- before(async () => {
+ for (let index = 0; index < roots.length; index++) {
+ const root = roots[index];
+ describe("Shared Modal on Init", async function () {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
await screen[root]();
console.log(`Root: ${root}`);
});
- beforeEach(async function() {});
+ beforeEach(async function () { });
- afterEach(async function() {
+ afterEach(async function () {
if (this.currentTest.state === "failed") {
await driver.logTestArtifacts(this.currentTest.title);
await driver.resetApp();
@@ -42,72 +46,73 @@ describe("modal-on-init:", () => {
}
});
- after("root after all hook", async function() {
+ after("root after all hook", async function () {
await driver.logTestArtifacts(`${root}_root_after_all_hook`);
});
- it("should shared modal view", async () => {
+ it("should shared modal view", async function () {
await assertComponent(driver, sharedModalView);
});
- it("run in background", async () => {
+ it("run in background", async function () {
await driver.backgroundApp(1);
await assertComponent(driver, sharedModalView);
});
- it("should close shared modal ", async () => {
+ it("should close shared modal ", async function () {
await screen.closeModal();
await screen.loadedHome();
});
- it("should open/close shared modal", async () => {
+ it("should open/close shared modal", async function () {
await screen.loadSharedModal(true);
await screen.closeModal();
await screen.loadedHome();
});
- it("should open/close shared modal again", async () => {
+ it("should open/close shared modal again", async function () {
await screen.loadSharedModal(true);
if (driver.isAndroid) {
- await driver.navBack();
- }else{
- await screen.closeModal();
+ await driver.navBack();
+ } else {
+ await screen.closeModal();
}
await screen.loadedHome();
});
- it("should open/close modal with frame", async () => {
+ it("should open/close modal with frame", async function () {
await screen.loadModalFrame(true);
await screen.closeModal();
});
- it("should open/close shared modal again", async () => {
+ it("should open/close shared modal again", async function () {
await screen.loadSharedModal(true);
await screen.closeModal();
});
- it("run in background again", async () => {
+ it("run in background again", async function () {
await driver.backgroundApp(1);
await screen.loadedHome();
});
- it("should open/close shared modal second", async () => {
- await screen.loadModalFrame(true);
- await screen.closeModal();
+ it("should open/close shared modal second", async function () {
+ await screen.loadModalFrame(true);
+ await screen.closeModal();
});
});
- });
+ };
- describe("Shared Modal on Init", () => {
+ describe("Shared Modal on Init", async function () {
const root = "setLayoutRootViewModal";
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
await screen[root]();
console.log(`Root: ${root}`);
});
- beforeEach(async function() {});
+ beforeEach(async function () { });
- afterEach(async function() {
+ afterEach(async function () {
if (this.currentTest.state === "failed") {
await driver.logTestArtifacts(this.currentTest.title);
await driver.resetApp();
@@ -115,40 +120,40 @@ describe("modal-on-init:", () => {
}
});
- after("root after all hook", async function() {
+ after("root after all hook", async function () {
await driver.logTestArtifacts(`${root}_root_after_all_hook`);
});
- it("should shared modal view", async () => {
+ it("should shared modal view", async function () {
await assertComponent(driver, sharedModalView);
});
- it("run in background", async () => {
+ it("run in background", async function () {
await driver.backgroundApp(1);
await assertComponent(driver, sharedModalView);
});
- it("should close shared modal ", async () => {
+ it("should close shared modal ", async function () {
await screen.closeModal();
await screen.loadedHome();
});
- it("should open/close shared modal", async () => {
+ it("should open/close shared modal", async function () {
await screen.loadModalFrame(true);
await screen.closeModal();
});
- it("run in background again", async () => {
+ it("run in background again", async function () {
await driver.backgroundApp(1);
await screen.loadedHome();
});
- it("should open/close shared modal second", async () => {
- await screen.loadModalFrame(true);
- await screen.closeModal();
+ it("should open/close shared modal second", async function () {
+ await screen.loadModalFrame(true);
+ await screen.closeModal();
});
- it("should open/close shared modal", async () => {
+ it("should open/close shared modal", async function () {
await screen.loadSharedModal(true);
await screen.closeModal();
});
diff --git a/e2e/modal-navigation-ng/e2e/modal.shared.e2e-spec.ts b/e2e/modal-navigation-ng/e2e/modal.shared.e2e-spec.ts
index fd76f81eb..97170ff88 100644
--- a/e2e/modal-navigation-ng/e2e/modal.shared.e2e-spec.ts
+++ b/e2e/modal-navigation-ng/e2e/modal.shared.e2e-spec.ts
@@ -1,29 +1,29 @@
-import { AppiumDriver, createDriver } from "nativescript-dev-appium";
+import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium";
import { Screen } from "./screens/screen"
import { assertComponent, goBack, navigateToSecondComponent } from "./screens/shared-screen";
const homeComponent = "Home Component";
const roots = ["setFrameRootView", "setTabRootView"];
-describe("modal-shared:", () => {
+describe("modal-shared:", async function () {
let driver: AppiumDriver;
let screen: Screen;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
screen = new Screen(driver);
});
- roots.forEach(root => {
- describe("Shared modal from second and back", () => {
+ for (let index = 0; index < roots.length; index++) {
+ const root = roots[index];
+ describe("Shared modal from home component and back", async function () {
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
await screen[root]();
});
- beforeEach(async function () {
- });
-
afterEach(async function () {
if (this.currentTest.state === "failed") {
await driver.logTestArtifacts(this.currentTest.title);
@@ -32,120 +32,128 @@ describe("modal-shared:", () => {
}
});
- it("should find home component", async () => {
+ it("should find home component", async function () {
await assertComponent(driver, homeComponent);
});
- it("should open/close shared modal from home component", async () => {
+ it("should open/close shared modal from home component", async function () {
await screen.loadSharedModal(true);
await screen.closeModal();
});
- it("should open/close shared modal from home component again", async () => {
+ it("should open/close shared modal from home component again", async function () {
await screen.loadSharedModal(true);
await screen.closeModal();
});
- it("should find home component again", async () => {
+ it("should open/close shared modal with presentation style from home component", async function () {
+ await screen.loadSharedModalWithPresentationStyle(true);
+ await screen.closeModal();
+ });
+
+ it("should find home component again", async function () {
await screen.loadedHome();
});
- it("should navigate to second component", async () => {
+ it("should navigate to second component", async function () {
await navigateToSecondComponent(driver);
});
- it("should find second component", async () => {
+ it("should find second component", async function () {
await assertComponent(driver, "second component");
});
- it("should open/close shared modal from second component", async () => {
+ it("should open/close shared modal from second component", async function () {
await screen.loadSharedModal(true);
await screen.closeModal();
});
- it("should find second component again", async () => {
+ it("should find second component again", async function () {
await assertComponent(driver, "second component");
});
- it("should navigate back to home component", async () => {
+ it("should navigate back to home component", async function () {
await goBack(driver);
await assertComponent(driver, homeComponent);
});
});
- });
+ };
- describe("modal-shared-different-component:", () => {
+ describe("modal-shared-different-component:", async function () {
let driver: AppiumDriver;
let screen: Screen;
-
- before(async () => {
+
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
screen = new Screen(driver);
});
-
- roots.forEach(root => {
- describe("Shared modal from different components", () => {
- before(async () => {
+
+ for (let index = 0; index < roots.length; index++) {
+ const root = roots[index];
+ describe("Shared modal from different components", async function () {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.resetApp();
});
-
- after(async () => {
+
+ after(async function () {
await driver.quit();
console.log("Quit driver!");
});
-
+
afterEach(async function () {
if (this.currentTest.state === "failed") {
await driver.logTestArtifacts(this.currentTest.title);
}
});
-
- it("should find home component", async () => {
+
+ it("should find home component", async function () {
await screen.loadedHome();
});
-
- it("should open/close shared modal from home component", async () => {
+
+ it("should open/close shared modal from home component", async function () {
await screen.loadSharedModal(true);
await screen.closeModal();
});
-
- it("should find home component again", async () => {
+
+ it("should find home component again", async function () {
await screen.loadedHome();
});
-
- it("should navigate to second component", async () => {
+
+ it("should navigate to second component", async function () {
await navigateToSecondComponent(driver);
});
-
- it("should find second component", async () => {
+
+ it("should find second component", async function () {
await assertComponent(driver, "second component");
});
-
- it("should open/close shared modal from second component", async () => {
+
+ it("should open/close shared modal from second component", async function () {
await screen.loadSharedModal(true);
await screen.closeModal();
});
-
- it("should find second component again", async () => {
+
+ it("should find second component again", async function () {
await assertComponent(driver, "second component");
});
-
- it("should navigate back to home component", async () => {
+
+ it("should navigate back to home component", async function () {
await goBack(driver);
await screen.loadedHome();
});
-
- it("should open/close shared modal from home component after manipulations with second", async () => {
+
+ it("should open/close shared modal from home component after manipulations with second", async function () {
await screen.loadSharedModal(true);
await screen.closeModal();
});
-
- it("should find home component again", async () => {
+
+ it("should find home component again", async function () {
await screen.loadedHome();
});
});
- });
+ };
});
});
diff --git a/e2e/modal-navigation-ng/e2e/screens/screen.ts b/e2e/modal-navigation-ng/e2e/screens/screen.ts
index 107d34b41..690edd0ab 100644
--- a/e2e/modal-navigation-ng/e2e/screens/screen.ts
+++ b/e2e/modal-navigation-ng/e2e/screens/screen.ts
@@ -1,4 +1,4 @@
-import { AppiumDriver } from "nativescript-dev-appium";
+import { AppiumDriver, SearchOptions } from "nativescript-dev-appium";
import { assert } from "chai";
const home = "Home Component"
@@ -165,6 +165,11 @@ export class Screen {
await btnTap.click();
}
+ private showSharedModalPresentationStyle = async () => {
+ const btnTap = await this._driver.findElementByText("popover", SearchOptions.contains);
+ await btnTap.click();
+ }
+
loadedModalPage = async () => {
const btnShowNestedModalPage = await this._driver.findElementByAutomationText(showNestedModalPage);
assert.isTrue(await btnShowNestedModalPage.isDisplayed(), `${showNestedModalPage} is not displayed`);
@@ -212,6 +217,7 @@ export class Screen {
}
loadedModalNoFrame = async () => {
+ await this._driver.wait(2000);
const btnShowDialogConfirm = await this._driver.waitForElement(showDialog);
const btnCloseModal = await this._driver.waitForElement(closeModal);
assert.isTrue(await btnShowDialogConfirm.isDisplayed());
@@ -309,4 +315,13 @@ export class Screen {
const lbl = await this._driver.waitForElement(sharedModalView, 5000);
assert.isTrue(await lbl.isDisplayed());
}
+
+ loadSharedModalWithPresentationStyle = async (loadShowModalPageWithFrame: boolean) => {
+ if (loadShowModalPageWithFrame) {
+ await this.showSharedModalPresentationStyle();
+ }
+
+ const lbl = await this._driver.waitForElement(sharedModalView, 5000);
+ assert.isTrue(await lbl.isDisplayed());
+ }
}
\ No newline at end of file
diff --git a/e2e/modal-navigation-ng/e2e/setup.ts b/e2e/modal-navigation-ng/e2e/setup.ts
index 8b26e66e9..acfc6f70a 100644
--- a/e2e/modal-navigation-ng/e2e/setup.ts
+++ b/e2e/modal-navigation-ng/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();
-});
+});
\ No newline at end of file
diff --git a/e2e/modal-navigation-ng/package.json b/e2e/modal-navigation-ng/package.json
index 444d4b4ee..31c2d0eeb 100644
--- a/e2e/modal-navigation-ng/package.json
+++ b/e2e/modal-navigation-ng/package.json
@@ -32,20 +32,19 @@
"devDependencies": {
"@angular/compiler-cli": "~7.2.0",
"@ngtools/webpack": "~7.2.0",
- "@types/chai": "^4.0.2",
- "@types/mocha": "^5.2.5",
- "@types/node": "^10.12.12",
+ "@types/chai": "~4.1.7",
+ "@types/mocha": "~5.2.5",
+ "@types/node": "~10.12.18",
"babel-traverse": "6.26.0",
"babel-types": "6.26.0",
"babylon": "6.18.0",
- "chai": "^4.2.0",
"lazy": "1.0.11",
- "mocha": "^5.2.0",
- "mocha-junit-reporter": "^1.18.0",
- "mocha-multi": "^1.0.1",
+ "mocha": "~5.2.0",
+ "mochawesome": "~3.1.2",
"nativescript-dev-appium": "next",
"nativescript-dev-typescript": "next",
"nativescript-dev-webpack": "next",
+ "tns-platform-declarations": "next",
"typescript": "~3.1.1"
},
"scripts": {
diff --git a/e2e/modal-navigation-ng/references.d.ts b/e2e/modal-navigation-ng/references.d.ts
new file mode 100644
index 000000000..b945d69c5
--- /dev/null
+++ b/e2e/modal-navigation-ng/references.d.ts
@@ -0,0 +1 @@
+///
\ No newline at end of file
diff --git a/e2e/nested-router-tab-view/.gitignore b/e2e/nested-router-tab-view/.gitignore
index dbb747daa..e2c82407c 100644
--- a/e2e/nested-router-tab-view/.gitignore
+++ b/e2e/nested-router-tab-view/.gitignore
@@ -9,4 +9,5 @@ hooks
e2e/reports
test-results.xml
-instrumentscli*.trace
\ No newline at end of file
+instrumentscli*.trace
+mochawesome-report
\ No newline at end of file
diff --git a/e2e/nested-router-tab-view/e2e/custom-tabs.e2e-spec.ts b/e2e/nested-router-tab-view/e2e/custom-tabs.e2e-spec.ts
index e41b858e3..654e2a3ff 100644
--- a/e2e/nested-router-tab-view/e2e/custom-tabs.e2e-spec.ts
+++ b/e2e/nested-router-tab-view/e2e/custom-tabs.e2e-spec.ts
@@ -1,4 +1,4 @@
-import { AppiumDriver, createDriver } from "nativescript-dev-appium";
+import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium";
import { Screen } from "./screen"
import {
testPlayerNavigated,
@@ -7,16 +7,17 @@ import {
testTeamNextNavigated,
} from "./shared.e2e-spec"
-describe("custom-tabs:", () => {
+describe("custom-tabs:", async function () {
let driver: AppiumDriver;
let screen: Screen;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
screen = new Screen(driver);
});
- after(async () => {
+ after(async function () {
await driver.quit();
console.log("Quit driver!");
});
@@ -27,7 +28,7 @@ describe("custom-tabs:", () => {
}
});
- it("loaded custom tab component and tabs", async () => {
+ it("loaded custom tab component and tabs", async function () {
await screen.navigateCustomTabsPage();
await screen.loadedCustomTabsPage();
await screen.loadedPlayersList();
@@ -35,7 +36,7 @@ describe("custom-tabs:", () => {
await screen.loadedTeamList();
});
- it("navigate back to login and again to custom tabs", async () => {
+ it("navigate back to login and again to custom tabs", async function () {
await backRoot(driver);
await screen.loadedLogin();
await screen.navigateCustomTabsPage();
@@ -45,7 +46,7 @@ describe("custom-tabs:", () => {
await screen.loadedTeamList();
});
- it("navigate back to login and again to custom tabs", async () => {
+ it("navigate back to login and again to custom tabs", async function () {
await gotoPlayersTab(driver);
await testPlayerNavigated(screen, screen.playerOne);
await gotoTeamsTab(driver);
diff --git a/e2e/nested-router-tab-view/e2e/home-tabs.e2e-spec.ts b/e2e/nested-router-tab-view/e2e/home-tabs.e2e-spec.ts
index af4d6e65e..9444c7177 100644
--- a/e2e/nested-router-tab-view/e2e/home-tabs.e2e-spec.ts
+++ b/e2e/nested-router-tab-view/e2e/home-tabs.e2e-spec.ts
@@ -1,4 +1,4 @@
-import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium";
+import { AppiumDriver, createDriver, SearchOptions, nsCapabilities } from "nativescript-dev-appium";
import { Screen } from "./screen"
import {
testPlayerNavigated,
@@ -12,22 +12,28 @@ import {
const pages = ["Go To Home Page", "Go To Lazy Home Page"];
-describe("home-tabs:", () => {
+describe("home-tabs:", async function () {
let driver: AppiumDriver;
let screen: Screen;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
screen = new Screen(driver);
});
- after(async () => {
+ after(async function () {
await driver.quit();
console.log("Quit driver!");
});
- pages.forEach(page => {
- describe(`${page} home-tab:`, () => {
+ for (let index = 0; index < pages.length; index++) {
+ const page = pages[index];
+ describe(`${page} home-tab:`, async function () {
+
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
+ });
afterEach(async function () {
if (this.currentTest.state === "failed") {
@@ -35,14 +41,14 @@ describe("home-tabs:", () => {
}
});
- it("loaded home component and lists", async () => {
+ it("loaded home component and lists", async function () {
await screen.navigateToHomePage(page);
await screen.loadedHome();
await screen.loadedPlayersList();
await screen.loadedTeamList();
});
- it("should navigate to Tabs then to About forward", async () => {
+ it("should navigate to Tabs then to About forward", async function () {
await screen.navigateToTabsPage();
await screen.loadedTabs();
await screen.loadedPlayersList();
@@ -51,7 +57,7 @@ describe("home-tabs:", () => {
await screen.loadedNestedAbout();
});
- it("should go back to Tabs and then back to Home", async () => {
+ it("should go back to Tabs and then back to Home", async function () {
await backActivatedRoute(driver);
await screen.loadedTabs();
await screen.loadedPlayersList();
@@ -61,7 +67,7 @@ describe("home-tabs:", () => {
await screen.loadedTeamList();
});
- it("should navigate to Tabs without Players/Teams navigation", async () => {
+ it("should navigate to Tabs without Players/Teams navigation", async function () {
await screen.navigateToTabsPage();
await screen.loadedTabs();
await screen.loadedPlayersList();
@@ -71,7 +77,7 @@ describe("home-tabs:", () => {
await screen.loadedTeamList();
});
- it("should navigate Player One/Team One then go to Tabs and back", async () => {
+ it("should navigate Player One/Team One then go to Tabs and back", async function () {
await testPlayerNavigated(screen, screen.playerOne);
await testTeamNavigated(screen, screen.teamOne);
await screen.navigateToTabsPage();
@@ -88,7 +94,7 @@ describe("home-tabs:", () => {
await screen.loadedTeamList();
});
- it("should navigate 2 times in Players go to Tabs and back", async () => {
+ it("should navigate 2 times in Players go to Tabs and back", async function () {
await testPlayerNavigated(screen, screen.playerOne);
await testPlayerNextNavigated(screen, screen.playerTwo);
await screen.navigateToTabsPage();
@@ -112,7 +118,7 @@ describe("home-tabs:", () => {
await screen.loadedLogin;
});
});
- });
+ };
});
async function backActivatedRoute(driver: AppiumDriver) {
diff --git a/e2e/nested-router-tab-view/e2e/setup.ts b/e2e/nested-router-tab-view/e2e/setup.ts
index 8b26e66e9..cd73140bb 100644
--- a/e2e/nested-router-tab-view/e2e/setup.ts
+++ b/e2e/nested-router-tab-view/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/e2e/nested-router-tab-view/e2e/split-view.e2e-spec.ts b/e2e/nested-router-tab-view/e2e/split-view.e2e-spec.ts
index abf6ce955..6b7710ebb 100644
--- a/e2e/nested-router-tab-view/e2e/split-view.e2e-spec.ts
+++ b/e2e/nested-router-tab-view/e2e/split-view.e2e-spec.ts
@@ -1,4 +1,4 @@
-import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium";
+import { AppiumDriver, createDriver, SearchOptions, nsCapabilities } from "nativescript-dev-appium";
import { Screen } from "./screen"
import {
testPlayerNavigated,
@@ -11,22 +11,29 @@ import {
const pages = ["Go To Home Page", "Go To Lazy Home Page"];
-describe("split-view:", () => {
+describe("split-view:", async function () {
let driver: AppiumDriver;
let screen: Screen;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
screen = new Screen(driver);
});
- after(async () => {
+ after(async function () {
await driver.quit();
console.log("Quit driver!");
});
- pages.forEach(page => {
- describe(`${page} split-view:`, () => {
+
+ for (let index = 0; index < pages.length; index++) {
+ const page = pages[index];
+ describe(`${page} split-view:`, async function () {
+
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
+ });
afterEach(async function () {
if (this.currentTest.state === "failed") {
@@ -34,7 +41,7 @@ describe("split-view:", () => {
}
});
- it("loaded home component and lists", async () => {
+ it("loaded home component and lists", async function () {
await screen.navigateToHomePage(page);
await screen.loadedHome();
await screen.loadedPlayersList();
@@ -42,7 +49,7 @@ describe("split-view:", () => {
await canGoBack(screen, screen.canGoBackActivatedRoute, true);
});
- it("should navigate Player One/Team One then back separately", async () => {
+ it("should navigate Player One/Team One then back separately", async function () {
await testPlayerNavigated(screen, screen.playerOne);
await testTeamNavigated(screen, screen.teamOne);
await canGoBack(screen, screen.canGoBackPlayers, true);
@@ -54,7 +61,7 @@ describe("split-view:", () => {
await screen.loadedTeamList();
});
- it("should navigate Player One/Team One then back separately (keep order)", async () => {
+ it("should navigate Player One/Team One then back separately (keep order)", async function () {
await testPlayerNavigated(screen, screen.playerOne);
await testTeamNavigated(screen, screen.teamOne);
await backTeams(driver);
@@ -63,7 +70,7 @@ describe("split-view:", () => {
await screen.loadedPlayersList();
});
- it("should navigate Player One/Team One then back simultaneously", async () => {
+ it("should navigate Player One/Team One then back simultaneously", async function () {
await testPlayerNavigated(screen, screen.playerOne);
await testTeamNavigated(screen, screen.teamOne);
await canGoBack(screen, screen.canGoBackBoth, true);
@@ -73,7 +80,7 @@ describe("split-view:", () => {
await screen.loadedPlayersList();
});
- it("should navigate Player One/Team One then next Player/Team then back separately", async () => {
+ it("should navigate Player One/Team One then next Player/Team then back separately", async function () {
await testPlayerNavigated(screen, screen.playerOne);
await testTeamNavigated(screen, screen.teamOne);
await testPlayerNextNavigated(screen, screen.playerTwo);
@@ -88,7 +95,7 @@ describe("split-view:", () => {
await screen.loadedPlayersList();
});
- it("should navigate Player One/Team One then back", async () => {
+ it("should navigate Player One/Team One then back", async function () {
await testPlayerNavigated(screen, screen.playerOne);
await testTeamNavigated(screen, screen.teamOne);
await back(driver);
@@ -99,7 +106,7 @@ describe("split-view:", () => {
await screen.loadedPlayersList();
});
- it("should navigate Player One then navigate Players list then back", async () => {
+ it("should navigate Player One then navigate Players list then back", async function () {
await testPlayerNavigated(screen, screen.playerOne);
await testPlayerNextNavigated(screen, screen.playerTwo);
await testPlayersNavigated(screen);
@@ -111,7 +118,7 @@ describe("split-view:", () => {
await screen.loadedPlayersList();
});
- it("should navigate Player One/Team One then Android back button", async () => {
+ it("should navigate Player One/Team One then Android back button", async function () {
if (driver.isAndroid) {
await testPlayerNavigated(screen, screen.playerOne);
await testTeamNavigated(screen, screen.teamOne);
@@ -148,7 +155,7 @@ describe("split-view:", () => {
await screen.loadedLogin;
});
});
- });
+ };
});
async function backActivatedRoute(driver: AppiumDriver) {
diff --git a/e2e/nested-router-tab-view/e2e/tab-view.e2e-spec.ts b/e2e/nested-router-tab-view/e2e/tab-view.e2e-spec.ts
index 3fa7b35e0..60d74c835 100644
--- a/e2e/nested-router-tab-view/e2e/tab-view.e2e-spec.ts
+++ b/e2e/nested-router-tab-view/e2e/tab-view.e2e-spec.ts
@@ -1,4 +1,4 @@
-import { AppiumDriver, createDriver } from "nativescript-dev-appium";
+import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium";
import { Screen } from "./screen"
import {
testPlayerNavigated,
@@ -7,16 +7,17 @@ import {
testTeamNextNavigated,
} from "./shared.e2e-spec"
-describe("tab-view:", () => {
+describe("tab-view:", async function () {
let driver: AppiumDriver;
let screen: Screen;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
screen = new Screen(driver);
});
- after(async () => {
+ after(async function () {
await driver.quit();
console.log("Quit driver!");
});
@@ -27,14 +28,14 @@ describe("tab-view:", () => {
}
});
- it("loaded home component and lists", async () => {
+ it("loaded home component and lists", async function () {
await screen.navigateToHomePage();
await screen.loadedHome();
await screen.loadedPlayersList();
await screen.loadedTeamList();
});
- it("loaded tabs component, Players List and Teams List pages", async () => {
+ it("loaded tabs component, Players List and Teams List pages", async function () {
await screen.navigateToTabsPage();
await screen.loadedTabs();
await screen.loadedPlayersList();
@@ -44,7 +45,7 @@ describe("tab-view:", () => {
await screen.loadedPlayersList();
});
- it("should navigate Player One/Team One then back separately", async () => {
+ it("should navigate Player One/Team One then back separately", async function () {
await testPlayerNavigated(screen, screen.playerOne);
await gotoTeamsTab(driver);
await testTeamNavigated(screen, screen.teamOne);
@@ -55,7 +56,7 @@ describe("tab-view:", () => {
await screen.loadedPlayersList();
});
- it("should navigate Player One/Team One then next Player/Team then back", async () => {
+ it("should navigate Player One/Team One then next Player/Team then back", async function () {
await testPlayerNavigated(screen, screen.playerOne);
await testPlayerNextNavigated(screen, screen.playerTwo);
await gotoTeamsTab(driver);
diff --git a/e2e/nested-router-tab-view/package.json b/e2e/nested-router-tab-view/package.json
index d4398ba15..ff096ee2f 100644
--- a/e2e/nested-router-tab-view/package.json
+++ b/e2e/nested-router-tab-view/package.json
@@ -32,17 +32,15 @@
"devDependencies": {
"@angular/compiler-cli": "~7.2.0",
"@ngtools/webpack": "~7.2.0",
- "@types/chai": "^4.0.2",
- "@types/mocha": "^5.2.5",
- "@types/node": "^10.12.12",
+ "@types/chai": "~4.1.7",
+ "@types/mocha": "~5.2.5",
+ "@types/node": "~10.12.18",
"babel-traverse": "6.26.0",
"babel-types": "6.26.0",
"babylon": "6.18.0",
- "chai": "^4.2.0",
"lazy": "1.0.11",
- "mocha": "^5.2.0",
- "mocha-junit-reporter": "^1.18.0",
- "mocha-multi": "^1.0.1",
+ "mocha": "~5.2.0",
+ "mochawesome": "~3.1.2",
"nativescript-dev-appium": "next",
"nativescript-dev-typescript": "next",
"nativescript-dev-webpack": "next",
@@ -52,4 +50,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/e2e/renderer/.gitignore b/e2e/renderer/.gitignore
index 5a67ca289..f2486e508 100644
--- a/e2e/renderer/.gitignore
+++ b/e2e/renderer/.gitignore
@@ -6,4 +6,5 @@ app/**/*.js
e2e/**/*.js
test-results.xml
e2e/reports
+mochawesome-report
diff --git a/e2e/renderer/e2e/action-bar.e2e-spec.ts b/e2e/renderer/e2e/action-bar.e2e-spec.ts
index 011c17645..b03dad5da 100644
--- a/e2e/renderer/e2e/action-bar.e2e-spec.ts
+++ b/e2e/renderer/e2e/action-bar.e2e-spec.ts
@@ -2,22 +2,24 @@ import {
AppiumDriver,
createDriver,
SearchOptions,
- UIElement
+ UIElement,
+ nsCapabilities
} from "nativescript-dev-appium";
import { isOnTheLeft } from "./helpers/location";
import { assert } from "chai";
-describe("Action Bar scenario", () => {
+describe("Action Bar scenario", async function () {
let driver: AppiumDriver;
- describe("dynamically add/remove ActionItems", async () => {
+ describe("dynamically add/remove ActionItems", async function () {
let firstActionItem: UIElement;
let secondActionItem: UIElement;
let toggleFirstButton: UIElement;
let toggleSecondButton: UIElement;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
});
@@ -28,7 +30,7 @@ describe("Action Bar scenario", () => {
}
});
- it("should navigate to page", async () => {
+ it("should navigate to page", async function () {
const navigationButton =
await driver.findElementByAutomationText("ActionBar dynamic");
await navigationButton.click();
@@ -37,7 +39,7 @@ describe("Action Bar scenario", () => {
await driver.findElementByAutomationText("Action Bar Dynamic Items");
});
- it("should find elements", async () => {
+ it("should find elements", async function () {
firstActionItem = await driver.findElementByAutomationText("one");
secondActionItem = await driver.findElementByAutomationText("two");
@@ -45,12 +47,12 @@ describe("Action Bar scenario", () => {
toggleSecondButton = await driver.findElementByAutomationText("toggle 2");
});
- it("should initially render the action items in the correct order", async () => {
+ it("should initially render the action items in the correct order", async function () {
await checkOrderIsCorrect();
});
it("should detach first element when its condition is false", done => {
- (async () => {
+ (async function () {
await toggleFirst();
try {
@@ -61,13 +63,13 @@ describe("Action Bar scenario", () => {
})();
});
- it("should attach first element in the correct position", async () => {
+ it("should attach first element in the correct position", async function () {
await toggleFirst();
await checkOrderIsCorrect();
});
it("should detach second element when its condition is false", done => {
- (async () => {
+ (async function () {
await toggleSecond();
try {
@@ -78,12 +80,12 @@ describe("Action Bar scenario", () => {
})();
});
- it("should attach second element in the correct position", async () => {
+ it("should attach second element in the correct position", async function () {
await toggleSecond();
await checkOrderIsCorrect();
});
- it("should detach and then reattach both at correct places", async () => {
+ it("should detach and then reattach both at correct places", async function () {
await toggleFirst();
await toggleSecond();
@@ -93,25 +95,26 @@ describe("Action Bar scenario", () => {
await checkOrderIsCorrect();
});
- const checkOrderIsCorrect = async () => {
+ const checkOrderIsCorrect = async function () {
await isOnTheLeft(firstActionItem, secondActionItem);
};
- const toggleFirst = async () => {
+ const toggleFirst = async function () {
await toggleFirstButton.click();
};
- const toggleSecond = async () => {
+ const toggleSecond = async function () {
await toggleSecondButton.click();
};
});
- describe("Action Bar extension with dynamic ActionItem", async () => {
+ describe("Action Bar extension with dynamic ActionItem", async function () {
let toggleButton: UIElement;
let conditional: UIElement;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
});
@@ -122,33 +125,33 @@ describe("Action Bar scenario", () => {
}
});
- it("should navigate to page", async () => {
+ it("should navigate to page", async function () {
const navigationButton =
await driver.findElementByAutomationText("ActionBarExtension");
await navigationButton.click();
});
- it("should find elements", async () => {
+ it("should find elements", async function () {
toggleButton = await driver.findElementByAutomationText("toggle");
conditional = await driver.findElementByAutomationText("conditional");
});
- it("should detach conditional action item when its condition is false", async () => {
+ it("should detach conditional action item when its condition is false", async function () {
await toggle();
const conditionalBtn = await driver.waitForElement("conditional", 1000);
assert.isUndefined(conditionalBtn, "Conditional button should not be visible!");
});
- it("should reattach conditional action item at correct place", async () => {
+ it("should reattach conditional action item at correct place", async function () {
await toggle();
await checkOrderIsCorrect();
});
-
- const checkOrderIsCorrect = async () => {
+
+ const checkOrderIsCorrect = async function () {
await isOnTheLeft(toggleButton, conditional);
};
- const toggle = async () => {
+ const toggle = async function () {
await toggleButton.click();
};
});
diff --git a/e2e/renderer/e2e/ngfor.e2e-spec.ts b/e2e/renderer/e2e/ngfor.e2e-spec.ts
index 007def76f..1b9fb1331 100644
--- a/e2e/renderer/e2e/ngfor.e2e-spec.ts
+++ b/e2e/renderer/e2e/ngfor.e2e-spec.ts
@@ -2,19 +2,21 @@ import {
AppiumDriver,
createDriver,
SearchOptions,
- UIElement
+ UIElement,
+ nsCapabilities
} from "nativescript-dev-appium";
import { isAbove } from "./helpers/location";
-describe("ngFor scenario", () => {
+describe("ngFor scenario", async function () {
let driver: AppiumDriver;
let addButton: UIElement;
let removeButton: UIElement;
let elements: UIElement[] = [];
let lastAddedElementId = 0;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
});
@@ -25,7 +27,7 @@ describe("ngFor scenario", () => {
}
});
- it("should navigate to page", async () => {
+ it("should navigate to page", async function () {
const navigationButton =
await driver.findElementByAutomationText("NgFor");
await navigationButton.click();
@@ -34,7 +36,7 @@ describe("ngFor scenario", () => {
await driver.findElementByAutomationText("ngFor");
});
- it("should find elements", async () => {
+ it("should find elements", async function () {
const first = await driver.findElementByAutomationText(
lastAddedElementId.toString());
elements.push(first);
@@ -45,39 +47,39 @@ describe("ngFor scenario", () => {
await isAbove(first, addButton);
});
- it("should render elements in correct order", async () => {
+ it("should render elements in correct order", async function () {
await isAbove(elements[0], addButton);
await isAbove(addButton, removeButton);
});
- it("should place new elements in the right places", async () => {
+ it("should place new elements in the right places", async function () {
for (let i = 0; i < 5; i += 1) {
await addElement();
await checkAppendedCorrectly();
}
});
- it("shouldn't reorder elements when last is removed", async () => {
+ it("shouldn't reorder elements when last is removed", async function () {
while (elements.length) {
await removeElement();
await checkCorrectOrderAll();
}
});
- it("should render new elements correctly after all old ones are removed", async () => {
+ it("should render new elements correctly after all old ones are removed", async function () {
for (let i = 0; i < 5; i += 1) {
await addElement();
await checkCorrectOrderAll();
}
});
- it("shouldn't reorder elements when middle is removed", async () => {
+ it("shouldn't reorder elements when middle is removed", async function () {
const middleIndex = Math.floor(elements.length / 2);
await removeElement(middleIndex);
await checkCorrectOrderAll();
});
- const addElement = async () => {
+ const addElement = async function () {
await addButton.click();
lastAddedElementId += 1;
@@ -101,7 +103,7 @@ describe("ngFor scenario", () => {
lastAddedElementId -= 1;
};
- const checkAppendedCorrectly = async () => {
+ const checkAppendedCorrectly = async function () {
const lastAdded = await driver.findElementByAutomationText(
lastAddedElementId.toString());
@@ -110,7 +112,7 @@ describe("ngFor scenario", () => {
await isAbove(addButton, removeButton);
};
- const checkCorrectOrderAll = async () => {
+ const checkCorrectOrderAll = async function () {
for (let i = 0; i < elements.length - 1; i += 1) {
await isAbove(elements[i], elements[i + 1]);
}
diff --git a/e2e/renderer/e2e/ngforof.e2e-spec.ts b/e2e/renderer/e2e/ngforof.e2e-spec.ts
index 219fa08bb..5b272ff9d 100644
--- a/e2e/renderer/e2e/ngforof.e2e-spec.ts
+++ b/e2e/renderer/e2e/ngforof.e2e-spec.ts
@@ -2,7 +2,8 @@ import {
AppiumDriver,
createDriver,
SearchOptions,
- UIElement
+ UIElement,
+ nsCapabilities
} from "nativescript-dev-appium";
import { isAbove } from "./helpers/location";
@@ -20,7 +21,8 @@ describe("ngForOf scenario", function () {
let elements: ElementTuple[] = [];
let lastAddedElementId = 0;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
});
@@ -31,7 +33,7 @@ describe("ngForOf scenario", function () {
}
});
- it("should navigate to page", async () => {
+ it("should navigate to page", async function () {
const navigationButton =
await driver.findElementByAutomationText("NgForOf");
await navigationButton.click();
@@ -40,7 +42,7 @@ describe("ngForOf scenario", function () {
await driver.findElementByAutomationText("ngForOf");
});
- it("should find elements", async () => {
+ it("should find elements", async function () {
const firstElement = await getElement(lastAddedElementId);
elements.push(firstElement);
@@ -51,42 +53,42 @@ describe("ngForOf scenario", function () {
await isAbove(firstElement.button, addButton);
});
- it("should render elements in correct order", async () => {
+ it("should render elements in correct order", async function () {
await elementTupleCorrectlyRendered(elements[0]);
await isAbove(elements[0].button, addButton);
await isAbove(addButton, removeButton);
});
- it("should place new elements in the right places", async () => {
+ it("should place new elements in the right places", async function () {
for (let i = 0; i < 2; i += 1) {
await addElement();
await checkAppendedCorrectly();
}
});
- it("shouldn't reorder elements when last is removed", async () => {
+ it("shouldn't reorder elements when last is removed", async function () {
while (elements.length) {
await removeElement();
await checkCorrectOrderAll();
}
});
- it("should render new elements correctly after all old ones are removed", async () => {
+ it("should render new elements correctly after all old ones are removed", async function () {
for (let i = 0; i < 5; i += 1) {
await addElement();
await checkCorrectOrderAll();
}
});
- it("shouldn't reorder elements when middle is removed", async () => {
+ it("shouldn't reorder elements when middle is removed", async function () {
const middleIndex = Math.floor(elements.length / 2);
await removeElement(middleIndex);
await checkCorrectOrderAll();
});
- const addElement = async () => {
+ const addElement = async function () {
await addButton.click();
lastAddedElementId += 1;
@@ -112,7 +114,7 @@ describe("ngForOf scenario", function () {
lastAddedElementId -= 1;
};
- const checkAppendedCorrectly = async () => {
+ const checkAppendedCorrectly = async function () {
const lastAdded = await getElement(lastAddedElementId);
await elementIsAbove(elements.slice(-2)[0], lastAdded);
@@ -120,7 +122,7 @@ describe("ngForOf scenario", function () {
await isAbove(addButton, removeButton);
};
- const checkCorrectOrderAll = async () => {
+ const checkCorrectOrderAll = async function () {
for (let i = 0; i < elements.length - 1; i += 1) {
await elementIsAbove(elements[i], elements[i + 1]);
}
@@ -148,7 +150,7 @@ describe("ngForOf scenario", function () {
const getElement = async (id: number) => {
let label = null;
let button = null;
-
+
if (driver.platformName.toLowerCase().includes("ios")) {
label = await driver.findElementByAccessibilityId(
"label: " + id.toString());
diff --git a/e2e/renderer/e2e/ngif.e2e-spec.ts b/e2e/renderer/e2e/ngif.e2e-spec.ts
index e164114f8..128dc2b74 100644
--- a/e2e/renderer/e2e/ngif.e2e-spec.ts
+++ b/e2e/renderer/e2e/ngif.e2e-spec.ts
@@ -2,19 +2,21 @@ import {
AppiumDriver,
createDriver,
SearchOptions,
- UIElement
+ UIElement,
+ nsCapabilities
} from "nativescript-dev-appium";
import { isAbove } from "./helpers/location";
import { assert } from "chai";
-describe("ngIf scenario", () => {
+describe("ngIf scenario", async function () {
let driver: AppiumDriver;
let toggleButton: UIElement;
- describe("without layout", async () => {
- before(async () => {
+ describe("without layout", async function () {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
});
@@ -25,7 +27,7 @@ describe("ngIf scenario", () => {
}
});
- it("should navigate to page", async () => {
+ it("should navigate to page", async function () {
const navigationButton =
await driver.findElementByAutomationText("NgIf no layout");
await navigationButton.click();
@@ -34,27 +36,28 @@ describe("ngIf scenario", () => {
await driver.findElementByAutomationText("ngIf - no layout");
});
- it("should find elements", async () => {
+ it("should find elements", async function () {
await driver.findElementByAutomationText("false");
toggleButton = await driver.findElementByAutomationText("Toggle");
});
- it("show 'true' button when show is true", async () => {
+ it("show 'true' button when show is true", async function () {
await toggleButton.click();
await driver.findElementByAutomationText("true");
});
});
- describe("label inbetween", async () => {
+ describe("label inbetween", async function () {
let firstButton: UIElement;
let secondButton: UIElement;
let conditionalLabel: UIElement;
let toggle: UIElement;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
- await driver.driver.resetApp();
+ await driver.driver.resetApp();
});
afterEach(async function () {
@@ -63,7 +66,7 @@ describe("ngIf scenario", () => {
}
});
- it("should navigate to page", async () => {
+ it("should navigate to page", async function () {
const navigationButton =
await driver.findElementByAutomationText("NgIf inbetween");
await navigationButton.click();
@@ -72,7 +75,7 @@ describe("ngIf scenario", () => {
await driver.findElementByAutomationText("ngIf - inbetween");
});
- it("should find elements", async () => {
+ it("should find elements", async function () {
firstButton = await driver.findElementByAutomationText("Button 1");
secondButton = await driver.findElementByAutomationText("Button 2");
toggleButton = await driver.findElementByAutomationText("Toggle");
@@ -83,7 +86,7 @@ describe("ngIf scenario", () => {
});
it("detach label when condition is false", done => {
- (async () => {
+ (async function () {
await toggleButton.click();
try {
@@ -95,14 +98,15 @@ describe("ngIf scenario", () => {
});
});
- describe("with else template", async () => {
+ describe("with else template", async function () {
let ifButton: UIElement;
let elseButton: UIElement;
let toggle: UIElement;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
- await driver.driver.resetApp();
+ await driver.driver.resetApp();
});
afterEach(async function () {
@@ -111,7 +115,7 @@ describe("ngIf scenario", () => {
}
});
- it("should navigate to page", async () => {
+ it("should navigate to page", async function () {
const navigationButton =
await driver.findElementByAutomationText("NgIfElse");
await navigationButton.click();
@@ -120,7 +124,7 @@ describe("ngIf scenario", () => {
await driver.findElementByAutomationText("ngIfElse");
});
- it("should find elements", async () => {
+ it("should find elements", async function () {
toggleButton = await driver.findElementByAutomationText("Toggle");
ifButton = await driver.findElementByAutomationText("If");
});
@@ -131,7 +135,7 @@ describe("ngIf scenario", () => {
.catch(() => done());
});
- it("should attach 'else' template when condition is changed to false", async () => {
+ it("should attach 'else' template when condition is changed to false", async function () {
await toggleButton.click();
elseButton = await driver.findElementByAutomationText("Else");
@@ -144,7 +148,7 @@ describe("ngIf scenario", () => {
});
it("should swap the content when condition is changed", done => {
- (async () => {
+ (async function () {
await toggleButton.click();
try {
@@ -156,14 +160,15 @@ describe("ngIf scenario", () => {
});
});
- describe("with then-else template", async () => {
+ describe("with then-else template", async function () {
let thenButton: UIElement;
let elseButton: UIElement;
let toggle: UIElement;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
- await driver.driver.resetApp();
+ await driver.driver.resetApp();
});
afterEach(async function () {
@@ -172,7 +177,7 @@ describe("ngIf scenario", () => {
}
});
- it("should navigate to page", async () => {
+ it("should navigate to page", async function () {
const navigationButton =
await driver.findElementByAutomationText("NgIf Then Else");
await navigationButton.click();
@@ -181,7 +186,7 @@ describe("ngIf scenario", () => {
await driver.findElementByAutomationText("ngIf Then Else");
});
- it("should find elements", async () => {
+ it("should find elements", async function () {
toggleButton = await driver.findElementByAutomationText("Toggle");
thenButton = await driver.findElementByAutomationText("Then");
});
@@ -192,7 +197,7 @@ describe("ngIf scenario", () => {
.catch(() => done());
});
- it("should attach 'else' template when condition is changed to false", async () => {
+ it("should attach 'else' template when condition is changed to false", async function () {
await toggleButton.click();
elseButton = await driver.findElementByAutomationText("Else");
@@ -205,7 +210,7 @@ describe("ngIf scenario", () => {
});
it("should swap the content when condition is changed", done => {
- (async () => {
+ (async function () {
await toggleButton.click();
try {
@@ -217,14 +222,15 @@ describe("ngIf scenario", () => {
});
});
- describe("then-else templates inside content view", async () => {
+ describe("then-else templates inside content view", async function () {
let thenButton: UIElement;
let elseButton: UIElement;
let toggle: UIElement;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
- await driver.driver.resetApp();
+ await driver.driver.resetApp();
});
afterEach(async function () {
@@ -233,7 +239,7 @@ describe("ngIf scenario", () => {
}
});
- it("should navigate to page", async () => {
+ it("should navigate to page", async function () {
const navigationButton =
await driver.findElementByAutomationText("Content view");
await navigationButton.click();
@@ -242,7 +248,7 @@ describe("ngIf scenario", () => {
await driver.findElementByAutomationText("Content View");
});
- it("should find elements", async () => {
+ it("should find elements", async function () {
toggleButton = await driver.findElementByAutomationText("Toggle");
thenButton = await driver.findElementByAutomationText("Then");
});
@@ -253,7 +259,7 @@ describe("ngIf scenario", () => {
.catch(() => done());
});
- it("should attach 'else' template when condition is changed to false", async () => {
+ it("should attach 'else' template when condition is changed to false", async function () {
await toggleButton.click();
elseButton = await driver.findElementByAutomationText("Else");
@@ -266,7 +272,7 @@ describe("ngIf scenario", () => {
});
it("should swap the content when condition is changed", done => {
- (async () => {
+ (async function () {
await toggleButton.click();
try {
@@ -278,13 +284,14 @@ describe("ngIf scenario", () => {
});
});
- describe("subsequent ifs", async () => {
+ describe("subsequent ifs", async function () {
let firstButton: UIElement;
let secondButton: UIElement;
let firstLabel: UIElement;
let secondLabel: UIElement;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
});
@@ -294,14 +301,14 @@ describe("ngIf scenario", () => {
await driver.logTestArtifacts(this.currentTest.title);
}
});
-
- it("should navigate to page", async () => {
+
+ it("should navigate to page", async function () {
const navigationButton =
await driver.findElementByAutomationText("NgIf Subsequent Ifs");
await navigationButton.click();
});
- it("should find elements", async () => {
+ it("should find elements", async function () {
firstButton = await driver.findElementByAutomationText("Toggle first");
secondButton = await driver.findElementByAutomationText("Toggle second");
@@ -314,7 +321,7 @@ describe("ngIf scenario", () => {
assert.isDefined(secondLabel);
});
- it("should toggle on first view", async () => {
+ it("should toggle on first view", async function () {
await firstButton.click();
let conditional = await driver.findElementByAutomationText("first");
@@ -324,7 +331,7 @@ describe("ngIf scenario", () => {
});
it("should toggle off first view", done => {
- (async () => {
+ (async function () {
await firstButton.click();
driver.findElementsByAutomationText("first", 500)
@@ -333,7 +340,7 @@ describe("ngIf scenario", () => {
})();
});
- it("should toggle on second view", async () => {
+ it("should toggle on second view", async function () {
await secondButton.click();
let conditional = await driver.findElementByAutomationText("second");
@@ -342,7 +349,7 @@ describe("ngIf scenario", () => {
});
it("should toggle off second view", done => {
- (async () => {
+ (async function () {
await secondButton.click();
driver.findElementByAutomationText("first", 500)
@@ -351,7 +358,7 @@ describe("ngIf scenario", () => {
})();
});
- it("should toggle on both views", async () => {
+ it("should toggle on both views", async function () {
await firstButton.click();
await secondButton.click();
@@ -363,13 +370,13 @@ describe("ngIf scenario", () => {
});
it("should toggle off both views", done => {
- (async () => {
+ (async function () {
await firstButton.click();
await secondButton.click();
driver.findElementByAutomationText("first", 500)
.then(_ => { throw new Error("first label found!"); })
- .catch(() => {
+ .catch(async function () {
driver.findElementByAutomationText("second", 500)
.then(_ => { throw new Error("second label found!"); })
.catch(() => done());
@@ -377,7 +384,7 @@ describe("ngIf scenario", () => {
})();
});
- it("should toggle on both views in reverse", async () => {
+ it("should toggle on both views in reverse", async function () {
await secondButton.click();
await firstButton.click();
@@ -389,13 +396,13 @@ describe("ngIf scenario", () => {
});
it("should toggle off both views in reverse", done => {
- (async () => {
+ (async function () {
await secondButton.click();
await firstButton.click();
driver.findElementByAutomationText("first", 500)
.then(_ => { throw new Error("first label found!"); })
- .catch(() => {
+ .catch(async function () {
driver.findElementByAutomationText("second", 500)
.then(_ => { throw new Error("second label found!"); })
.catch(() => done());
diff --git a/e2e/renderer/e2e/page-router-outlet.e2e-spec.ts b/e2e/renderer/e2e/page-router-outlet.e2e-spec.ts
index ad79f6116..fb1ef8a84 100644
--- a/e2e/renderer/e2e/page-router-outlet.e2e-spec.ts
+++ b/e2e/renderer/e2e/page-router-outlet.e2e-spec.ts
@@ -2,15 +2,17 @@ import {
AppiumDriver,
createDriver,
SearchOptions,
- UIElement
+ UIElement,
+ nsCapabilities
} from "nativescript-dev-appium";
import { assert } from "chai";
-describe("page-router-outlet-scenario", () => {
+describe("page-router-outlet-scenario", async function () {
let driver: AppiumDriver;
- describe("actionBarVisibility 'always' shows action bars", async () => {
- before(async () => {
+ describe("actionBarVisibility 'always' shows action bars", async function () {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
});
@@ -21,7 +23,7 @@ describe("page-router-outlet-scenario", () => {
}
});
- it("should navigate to page", async () => {
+ it("should navigate to page", async function () {
const navigationButton =
await driver.findElementByAutomationText("ActionBarVisibility Always");
await navigationButton.click();
@@ -29,30 +31,31 @@ describe("page-router-outlet-scenario", () => {
await driver.findElementByAutomationText("ShowActionBar");
});
- it("should not hide action bar by default", async () => {
- const screenMatches = await driver.compareScreen("actionBarVisibility-always-default", 5);
+ it("should not hide action bar by default", async function () {
+ const screenMatches = await driver.compareScreen("actionBarVisibility-always-default", 5);
assert(screenMatches);
});
- it("should not hide action bar when hidden by page", async () => {
+ it("should not hide action bar when hidden by page", async function () {
const hideActionBarButton = await driver.findElementByAutomationText("HideActionBar");
hideActionBarButton.click();
- const screenMatches = await driver.compareScreen("actionBarVisibility-always-hidden", 5);
+ const screenMatches = await driver.compareScreen("actionBarVisibility-always-hidden", 5);
assert(screenMatches);
});
- it("should not do anything when shown action bar by page", async () => {
+ it("should not do anything when shown action bar by page", async function () {
const showActionBarButton = await driver.findElementByAutomationText("ShowActionBar");
showActionBarButton.click();
- const screenMatches = await driver.compareScreen("actionBarVisibility-always-shown", 5);
+ const screenMatches = await driver.compareScreen("actionBarVisibility-always-shown", 5);
assert(screenMatches);
});
});
- describe("actionBarVisibility 'never' doesn't show action bars", async () => {
- before(async () => {
+ describe("actionBarVisibility 'never' doesn't show action bars", async function () {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
});
@@ -63,7 +66,7 @@ describe("page-router-outlet-scenario", () => {
}
});
- it("should navigate to page", async () => {
+ it("should navigate to page", async function () {
const navigationButton =
await driver.findElementByAutomationText("ActionBarVisibility Never");
await navigationButton.click();
@@ -71,31 +74,32 @@ describe("page-router-outlet-scenario", () => {
await driver.findElementByAutomationText("ShowActionBar");
});
- it("should hide action bar by default", async () => {
- const screenMatches = await driver.compareScreen("actionBarVisibility-never-default", 5);
+ it("should hide action bar by default", async function () {
+ const screenMatches = await driver.compareScreen("actionBarVisibility-never-default", 5);
assert(screenMatches);
});
- it("should not show action bar when shown by page", async () => {
+ it("should not show action bar when shown by page", async function () {
const showActionBarButton = await driver.findElementByAutomationText("ShowActionBar");
showActionBarButton.click();
- const screenMatches = await driver.compareScreen("actionBarVisibility-never-shown", 5);
+ const screenMatches = await driver.compareScreen("actionBarVisibility-never-shown", 5);
assert(screenMatches);
});
- it("should not do anything when hidden action bar by page", async () => {
+ it("should not do anything when hidden action bar by page", async function () {
const hideActionBarButton = await driver.findElementByAutomationText("HideActionBar");
hideActionBarButton.click();
- const screenMatches = await driver.compareScreen("actionBarVisibility-never-hidden", 5);
+ const screenMatches = await driver.compareScreen("actionBarVisibility-never-hidden", 5);
assert(screenMatches);
});
});
- describe("actionBarVisibility 'never' doesn't show action bars in lazy module page", async () => {
+ describe("actionBarVisibility 'never' doesn't show action bars in lazy module page", async function () {
let imagePostFix = "";
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
if (driver.isIOS && driver.nsCapabilities.device.name.toLowerCase().includes("x")) {
@@ -109,7 +113,7 @@ describe("page-router-outlet-scenario", () => {
}
});
- it("should navigate to page", async () => {
+ it("should navigate to page", async function () {
const navigationButton =
await driver.findElementByAutomationText("ActionBarVisibility Never Lazy");
await navigationButton.click();
@@ -117,30 +121,31 @@ describe("page-router-outlet-scenario", () => {
await driver.findElementByAutomationText("ShowActionBar");
});
- it("should hide action bar by default", async () => {
- const screenMatches = await driver.compareScreen(`actionBarVisibility-never-default${imagePostFix}`, 5);
+ it("should hide action bar by default", async function () {
+ const screenMatches = await driver.compareScreen(`actionBarVisibility-never-default${imagePostFix}`, 5);
assert(screenMatches);
});
- it("should not show action bar when shown by page", async () => {
+ it("should not show action bar when shown by page", async function () {
const showActionBarButton = await driver.findElementByAutomationText("ShowActionBar");
showActionBarButton.click();
- const screenMatches = await driver.compareScreen(`actionBarVisibility-never-shown${imagePostFix}`, 5);
+ const screenMatches = await driver.compareScreen(`actionBarVisibility-never-shown${imagePostFix}`, 5);
assert(screenMatches);
});
- it("should not do anything when hidden action bar by page", async () => {
+ it("should not do anything when hidden action bar by page", async function () {
const hideActionBarButton = await driver.findElementByAutomationText("HideActionBar");
hideActionBarButton.click();
- const screenMatches = await driver.compareScreen(`actionBarVisibility-never-hidden${imagePostFix}`, 5);
+ const screenMatches = await driver.compareScreen(`actionBarVisibility-never-hidden${imagePostFix}`, 5);
assert(screenMatches);
});
});
- describe("actionBarVisibility 'auto' shows action bars based on page", async () => {
- before(async () => {
+ describe("actionBarVisibility 'auto' shows action bars based on page", async function () {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
});
@@ -151,7 +156,7 @@ describe("page-router-outlet-scenario", () => {
}
});
- it("should navigate to page", async () => {
+ it("should navigate to page", async function () {
const navigationButton =
await driver.findElementByAutomationText("ActionBarVisibility Auto");
await navigationButton.click();
@@ -159,24 +164,24 @@ describe("page-router-outlet-scenario", () => {
await driver.findElementByAutomationText("ShowActionBar");
});
- it("should show action bar by default", async () => {
- const screenMatches = await driver.compareScreen("actionBarVisibility-auto-default", 5);
+ it("should show action bar by default", async function () {
+ const screenMatches = await driver.compareScreen("actionBarVisibility-auto-default", 5);
assert(screenMatches);
});
- it("should hide action bar when hidden by page", async () => {
+ it("should hide action bar when hidden by page", async function () {
const hideActionBarButton = await driver.findElementByAutomationText("HideActionBar");
hideActionBarButton.click();
- const screenMatches = await driver.compareScreen("actionBarVisibility-auto-hidden", 5);
+ const screenMatches = await driver.compareScreen("actionBarVisibility-auto-hidden", 5);
assert(screenMatches);
});
- it("should show action bar when shown by page", async () => {
+ it("should show action bar when shown by page", async function () {
const showActionBarButton = await driver.findElementByAutomationText("ShowActionBar");
showActionBarButton.click();
- const screenMatches = await driver.compareScreen("actionBarVisibility-auto-shown", 5);
+ const screenMatches = await driver.compareScreen("actionBarVisibility-auto-shown", 5);
assert(screenMatches);
});
});
diff --git a/e2e/renderer/e2e/setup.ts b/e2e/renderer/e2e/setup.ts
index d52e381d0..11b854fca 100644
--- a/e2e/renderer/e2e/setup.ts
+++ b/e2e/renderer/e2e/setup.ts
@@ -1,13 +1,19 @@
-import { startServer, stopServer, createDriver, AppiumDriver } from "nativescript-dev-appium";
+import { startServer, stopServer, ITestReporter, nsCapabilities, LogImageType } from "nativescript-dev-appium";
+const addContext = require('mochawesome/addContext');
-let driver: AppiumDriver;
+const testReporterContext = {};
+testReporterContext.name = "mochawesome";
+testReporterContext.reportDir = "mochawesome-report";
+testReporterContext.log = addContext;
+testReporterContext.logImageTypes = [LogImageType.screenshots];
+nsCapabilities.testReporter = testReporterContext;
-before("start server", async () => {
+before("start server", async function () {
+ nsCapabilities.testReporter.context = this;
await startServer();
- driver = await createDriver();
});
-after("stop server", async () => {
- await driver.quit();
+after("stop server", async function () {
+ nsCapabilities.testReporter.context = this;
await stopServer();
-});
\ No newline at end of file
+});
diff --git a/e2e/renderer/e2e/tab-view.e2e-spec.ts b/e2e/renderer/e2e/tab-view.e2e-spec.ts
index f5415289f..82f3b6f58 100644
--- a/e2e/renderer/e2e/tab-view.e2e-spec.ts
+++ b/e2e/renderer/e2e/tab-view.e2e-spec.ts
@@ -2,19 +2,21 @@ import {
AppiumDriver,
createDriver,
SearchOptions,
- UIElement
+ UIElement,
+ nsCapabilities
} from "nativescript-dev-appium";
import { assert } from "chai";
-describe("TabView-scenario", () => {
+describe("TabView-scenario", async function(){
let driver: AppiumDriver;
- describe("dynamically change TabView item title, icon and textTransform", async () => {
+ describe("dynamically change TabView item title, icon and textTransform", async function(){
let firstTabItem: UIElement;
let secondTabItem: UIElement;
let thirdTabItem: UIElement;
- before(async () => {
+ before(async function(){
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.driver.resetApp();
});
@@ -25,7 +27,7 @@ describe("TabView-scenario", () => {
}
});
- it("should navigate to page", async () => {
+ it("should navigate to page", async function(){
const navigationButton =
await driver.findElementByAutomationText("TabItem Binding");
await navigationButton.click();
@@ -33,7 +35,7 @@ describe("TabView-scenario", () => {
await driver.findElementByAutomationText("Tab Item Binding");
});
- it("should find elements", async () => {
+ it("should find elements", async function(){
await driver.findElementByAutomationText("First Tab");
const notSelectedTabItems = await driver.findElementsByText("not selected");
@@ -46,7 +48,7 @@ describe("TabView-scenario", () => {
assert(screenMatches);
});
- it("should navigate to second tab item", async () => {
+ it("should navigate to second tab item", async function(){
await secondTabItem.click();
await driver.findElementByAutomationText("Second Tab");
@@ -61,7 +63,7 @@ describe("TabView-scenario", () => {
assert(screenMatches);
});
- it("should navigate to third tab item", async () => {
+ it("should navigate to third tab item", async function(){
await thirdTabItem.click();
await driver.findElementByAutomationText("Third Tab");
diff --git a/e2e/renderer/package.json b/e2e/renderer/package.json
index 8683bd45b..e32d7588e 100644
--- a/e2e/renderer/package.json
+++ b/e2e/renderer/package.json
@@ -25,19 +25,17 @@
"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",
+ "@types/chai": "~4.1.7",
+ "@types/mocha": "~5.2.5",
+ "@types/node": "~10.12.18",
"babel-traverse": "6.25.0",
"babel-types": "6.25.0",
"babylon": "6.17.4",
- "chai": "~4.1.1",
"chai-as-promised": "~7.1.1",
"colors": "^1.1.2",
"lazy": "1.0.11",
- "mocha": "~5.1.0",
- "mocha-junit-reporter": "~1.17.0",
- "mocha-multi": "~1.0.0",
+ "mocha": "~5.2.0",
+ "mochawesome": "~3.1.2",
"nativescript-dev-appium": "next",
"nativescript-dev-typescript": "next",
"nativescript-dev-webpack": "next",
diff --git a/e2e/router-tab-view/.gitignore b/e2e/router-tab-view/.gitignore
index dbb747daa..e2c82407c 100644
--- a/e2e/router-tab-view/.gitignore
+++ b/e2e/router-tab-view/.gitignore
@@ -9,4 +9,5 @@ hooks
e2e/reports
test-results.xml
-instrumentscli*.trace
\ No newline at end of file
+instrumentscli*.trace
+mochawesome-report
\ No newline at end of file
diff --git a/e2e/router-tab-view/e2e/setup.ts b/e2e/router-tab-view/e2e/setup.ts
index 8b26e66e9..cd73140bb 100644
--- a/e2e/router-tab-view/e2e/setup.ts
+++ b/e2e/router-tab-view/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/e2e/router-tab-view/e2e/tab-view-navigation.e2e-spec.ts b/e2e/router-tab-view/e2e/tab-view-navigation.e2e-spec.ts
index b57be824d..f0ead8efa 100644
--- a/e2e/router-tab-view/e2e/tab-view-navigation.e2e-spec.ts
+++ b/e2e/router-tab-view/e2e/tab-view-navigation.e2e-spec.ts
@@ -1,31 +1,27 @@
-import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium";
+import { AppiumDriver, createDriver, SearchOptions, nsCapabilities } from "nativescript-dev-appium";
import { assert } from "chai";
-describe("TabView with page-router-outlet in each tab", () => {
+describe("TabView with page-router-outlet in each tab", async function () {
let driver: AppiumDriver;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
});
- after(async () => {
- await driver.quit();
- console.log("Quit driver!");
- });
-
afterEach(async function () {
if (this.currentTest.state === "failed") {
await driver.logTestArtifacts(this.currentTest.title);
}
});
- it("should find any tabs by text", async () => {
+ it("should find any tabs by text", async function () {
await driver.findElementByAutomationText("Players");
await driver.findElementByAutomationText("Teams");
await driver.findElementByAutomationText("Player List");
});
- it("should be able to switch between tabs", async () => {
+ it("should be able to switch between tabs", async function () {
await driver.findElementByAutomationText("Player List");
await selectTeamTab(driver);
@@ -33,7 +29,7 @@ describe("TabView with page-router-outlet in each tab", () => {
await selectPlayerTab(driver);
});
- it("should go forward and go back on first(player) tab", async () => {
+ it("should go forward and go back on first(player) tab", async function () {
await driver.findElementByAutomationText("Player List");
await navigateToPlayerItem(driver, "Player One", "1");
@@ -42,7 +38,7 @@ describe("TabView with page-router-outlet in each tab", () => {
await driver.findElementByAutomationText("Player List");
});
- it("should go forward and go back on second(team) tab", async () => {
+ it("should go forward and go back on second(team) tab", async function () {
await driver.findElementByAutomationText("Player List");
await selectTeamTab(driver);
@@ -55,7 +51,7 @@ describe("TabView with page-router-outlet in each tab", () => {
await selectPlayerTab(driver);
});
- it("should navigate first(player) tab, second(team) tab and back in the same order ", async () => {
+ it("should navigate first(player) tab, second(team) tab and back in the same order ", async function () {
await driver.findElementByAutomationText("Player List");
// Go forward in player tab
@@ -79,7 +75,7 @@ describe("TabView with page-router-outlet in each tab", () => {
await driver.findElementByAutomationText("Player List");
});
- it("should navigate second(team) tab, first(player) and back in the same order ", async () => {
+ it("should navigate second(team) tab, first(player) and back in the same order ", async function () {
await driver.findElementByAutomationText("Player List");
// Go forward in team tab
@@ -106,7 +102,7 @@ describe("TabView with page-router-outlet in each tab", () => {
await selectPlayerTab(driver);
});
- it("should navigate first(player) tab, second(team) tab and back in reverse order ", async () => {
+ it("should navigate first(player) tab, second(team) tab and back in reverse order ", async function () {
await driver.findElementByAutomationText("Player List");
// Go forward in player tab
@@ -129,10 +125,10 @@ describe("TabView with page-router-outlet in each tab", () => {
await driver.navBack();
await driver.findElementByAutomationText("Team List");
- await selectPlayerTab(driver);
+ await selectPlayerTab(driver);
});
- it("should navigate second(team) tab, first(player) tab and back in reverse order ", async () => {
+ it("should navigate second(team) tab, first(player) tab and back in reverse order ", async function () {
await driver.findElementByAutomationText("Player List");
// Go forward in team tab
diff --git a/e2e/router-tab-view/package.json b/e2e/router-tab-view/package.json
index d4a2a71db..0672cbcfc 100644
--- a/e2e/router-tab-view/package.json
+++ b/e2e/router-tab-view/package.json
@@ -6,10 +6,10 @@
"nativescript": {
"id": "org.nativescript.routertabview",
"tns-android": {
- "version": "3.4.1-2018-02-06-02"
+ "version": "next"
},
"tns-ios": {
- "version": "3.4.1"
+ "version": "next"
}
},
"dependencies": {
@@ -30,16 +30,15 @@
"zone.js": "^0.8.4"
},
"devDependencies": {
- "@types/chai": "^4.0.2",
- "@types/mocha": "^5.2.5",
- "@types/node": "^10.12.12",
+ "@types/chai": "~4.1.7",
+ "@types/mocha": "~5.2.5",
+ "@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.1.0",
- "mocha-junit-reporter": "~1.17.0",
- "mocha-multi": "~1.0.0",
+ "mocha": "~5.2.0",
+ "mochawesome": "~3.1.2",
"nativescript-dev-appium": "next",
"nativescript-dev-typescript": "next",
"typescript": "~3.1.1"
diff --git a/e2e/router/.gitignore b/e2e/router/.gitignore
index 8e824499e..e3eb2283a 100644
--- a/e2e/router/.gitignore
+++ b/e2e/router/.gitignore
@@ -7,4 +7,5 @@ hooks
/**/*.js
/**/*.map
e2e/reports
-test-results.xml
\ No newline at end of file
+test-results.xml
+mochawesome-report
\ No newline at end of file
diff --git a/e2e/router/app/counter.service.ts b/e2e/router/app/counter.service.ts
new file mode 100644
index 000000000..15fe455c1
--- /dev/null
+++ b/e2e/router/app/counter.service.ts
@@ -0,0 +1,13 @@
+import { Injectable } from "@angular/core";
+import { BehaviorSubject } from "rxjs";
+
+@Injectable({
+ providedIn: "root"
+})
+export class CounterService {
+ counter$ = new BehaviorSubject(0);
+
+ tick() {
+ this.counter$.next(this.counter$.value + 1);
+ }
+}
\ No newline at end of file
diff --git a/e2e/router/app/first/first.component.ts b/e2e/router/app/first/first.component.ts
index 5d93d97b7..f76f54f91 100644
--- a/e2e/router/app/first/first.component.ts
+++ b/e2e/router/app/first/first.component.ts
@@ -1,10 +1,9 @@
import { Component, OnInit, OnDestroy, OnChanges, DoCheck } from "@angular/core";
-import { ActivatedRoute, Router, Route } from "@angular/router";
-import { Location } from "@angular/common";
import { RouterExtensions } from "nativescript-angular/router";
-
import { Page } from "tns-core-modules/ui/page";
+import { CounterService } from "../counter.service";
+
@Component({
selector: "first",
template: `
@@ -21,12 +20,18 @@ import { Page } from "tns-core-modules/ui/page";
+
`
})
export class FirstComponent implements OnInit, OnDestroy, DoCheck {
public message: string = "";
public doCheckCount: number = 0;
- constructor(private routerExt: RouterExtensions, page: Page) {
+
+ constructor(
+ private routerExt: RouterExtensions,
+ public service: CounterService,
+ page: Page) {
+
console.log("FirstComponent - constructor() page: " + page);
}
@@ -42,7 +47,7 @@ export class FirstComponent implements OnInit, OnDestroy, DoCheck {
this.doCheckCount++;
console.log("FirstComponent - ngDoCheck(): " + this.doCheckCount);
}
-
+
reset() {
this.doCheckCount = 0;
}
diff --git a/e2e/router/app/second/second.component.ts b/e2e/router/app/second/second.component.ts
index be9baae96..fbdaeaee5 100644
--- a/e2e/router/app/second/second.component.ts
+++ b/e2e/router/app/second/second.component.ts
@@ -1,10 +1,11 @@
import { Component, OnInit, OnDestroy } from "@angular/core";
-import { ActivatedRoute, Router, Route } from "@angular/router";
+import { ActivatedRoute } from "@angular/router";
import { RouterExtensions } from "nativescript-angular/router";
import { Page } from "tns-core-modules/ui/page";
import { Observable } from "rxjs";
import { map } from "rxjs/operators";
+import { CounterService } from "../counter.service";
@Component({
selector: "second",
@@ -13,11 +14,14 @@ import { map } from "rxjs/operators";
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -33,7 +37,11 @@ export class SecondComponent implements OnInit, OnDestroy {
public depth$: Observable;
public nextDepth$: Observable;
- constructor(private routerExt: RouterExtensions, private route: ActivatedRoute, page: Page) {
+ constructor(
+ private routerExt: RouterExtensions,
+ private route: ActivatedRoute,
+ public service: CounterService,
+ page: Page) {
console.log("SecondComponent - constructor() page: " + page);
this.depth$ = route.params.pipe(map(r => r["depth"]));
this.nextDepth$ = route.params.pipe(map(r => +r["depth"] + 1));
diff --git a/e2e/router/e2e/router.e2e-spec.ts b/e2e/router/e2e/router.e2e-spec.ts
index ba69f92ef..b71926499 100644
--- a/e2e/router/e2e/router.e2e-spec.ts
+++ b/e2e/router/e2e/router.e2e-spec.ts
@@ -3,53 +3,56 @@ import {
UIElement,
createDriver,
SearchOptions,
+ nsCapabilities,
} from "nativescript-dev-appium";
-describe("Simple navigate and back", () => {
+describe("Simple navigate and back", async function(){
let driver: AppiumDriver;
- before(async () => {
+ before(async function(){
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.resetApp();
});
- it("should find First", async () => {
+ it("should find First", async function(){
await assureFirstComponent(driver);
});
- it("should navigate to Second(1)/master", async () => {
+ it("should navigate to Second(1)/master", async function(){
await findAndClick(driver, "GO TO SECOND");
await assureSecondComponent(driver, 1);
await assureNestedMasterComponent(driver);
});
- it("should navigate back to First", async () => {
+ it("should navigate back to First", async function(){
await goBack(driver);
await assureFirstComponent(driver);
});
});
-describe("Navigate inside nested outlet", () => {
+describe("Navigate inside nested outlet", async function(){
let driver: AppiumDriver;
- before(async () => {
+ before(async function(){
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.resetApp();
});
- it("should find First", async () => {
+ it("should find First", async function(){
await assureFirstComponent(driver);
});
- it("should navigate to Second(1)/master", async () => {
+ it("should navigate to Second(1)/master", async function(){
await findAndClick(driver, "GO TO SECOND");
await assureSecondComponent(driver, 1)
await assureNestedMasterComponent(driver);
});
- it("should navigate to Second(1)/detail(1) and back", async () => {
+ it("should navigate to Second(1)/detail(1) and back", async function(){
const detailBtn = await driver.findElementByAutomationText("DETAIL 1");
detailBtn.click();
await assureSecondComponent(driver, 1)
@@ -60,7 +63,7 @@ describe("Navigate inside nested outlet", () => {
await assureNestedMasterComponent(driver);
});
- it("should navigate to Second(1)/detail(2) and back", async () => {
+ it("should navigate to Second(1)/detail(2) and back", async function(){
const detailBtn = await driver.findElementByAutomationText("DETAIL 2");
detailBtn.click();
await assureSecondComponent(driver, 1)
@@ -71,32 +74,33 @@ describe("Navigate inside nested outlet", () => {
await assureNestedMasterComponent(driver);
});
- it("should navigate back to First", async () => {
+ it("should navigate back to First", async function(){
await goBack(driver);
await assureFirstComponent(driver);
});
});
-describe("Navigate to same component with different param", () => {
+describe("Navigate to same component with different param", async function(){
let driver: AppiumDriver;
- before(async () => {
+ before(async function(){
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.resetApp();
});
- it("should find First", async () => {
+ it("should find First", async function(){
await assureFirstComponent(driver);
});
- it("should navigate to Second(1)/master", async () => {
+ it("should navigate to Second(1)/master", async function(){
await findAndClick(driver, "GO TO SECOND");
await assureSecondComponent(driver, 1)
await assureNestedMasterComponent(driver);
});
- it("should navigate to Second(2)/master", async () => {
+ it("should navigate to Second(2)/master", async function(){
const navigationButton =
await driver.findElementByAutomationText("GO TO NEXT SECOND");
navigationButton.click();
@@ -105,39 +109,40 @@ describe("Navigate to same component with different param", () => {
await assureNestedMasterComponent(driver);
});
- it("should navigate back to Second(1)/master", async () => {
+ it("should navigate back to Second(1)/master", async function(){
await goBack(driver);
await assureSecondComponent(driver, 1)
await assureNestedMasterComponent(driver);
});
- it("should navigate back to First", async () => {
+ it("should navigate back to First", async function(){
await goBack(driver);
await assureFirstComponent(driver);
});
});
-describe("Nested navigation + page navigation", () => {
+describe("Nested navigation + page navigation", async function(){
let driver: AppiumDriver;
- before(async () => {
+ before(async function(){
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.resetApp();
});
- it("should find First", async () => {
+ it("should find First", async function(){
await assureFirstComponent(driver);
});
- it("should navigate to Second(1)/master", async () => {
+ it("should navigate to Second(1)/master", async function(){
await findAndClick(driver, "GO TO SECOND");
await assureSecondComponent(driver, 1)
await assureNestedMasterComponent(driver);
});
- it("should navigate to Second(1)/detail(1)", async () => {
+ it("should navigate to Second(1)/detail(1)", async function(){
const detailBtn = await driver.findElementByAutomationText("DETAIL 1");
detailBtn.click();
@@ -145,7 +150,7 @@ describe("Nested navigation + page navigation", () => {
await assureNestedDetailComponent(driver, 1);
});
- it("should navigate to Second(2)/master", async () => {
+ it("should navigate to Second(2)/master", async function(){
const navigationButton =
await driver.findElementByAutomationText("GO TO NEXT SECOND");
navigationButton.click();
@@ -154,7 +159,7 @@ describe("Nested navigation + page navigation", () => {
await assureNestedMasterComponent(driver);
});
- it("should navigate to Second(2)/detail(2)", async () => {
+ it("should navigate to Second(2)/detail(2)", async function(){
const detailBtn = await driver.findElementByAutomationText("DETAIL 2");
detailBtn.click();
@@ -162,13 +167,13 @@ describe("Nested navigation + page navigation", () => {
await assureNestedDetailComponent(driver, 2);
});
- it("should navigate to First", async () => {
+ it("should navigate to First", async function(){
await findAndClick(driver, "GO TO FIRST");
await assureFirstComponent(driver);
});
- it("should navigate the whole stack", async () => {
+ it("should navigate the whole stack", async function(){
await goBack(driver);
await assureSecondComponent(driver, 2)
await assureNestedDetailComponent(driver, 2);
@@ -190,31 +195,32 @@ describe("Nested navigation + page navigation", () => {
});
});
-describe("Nested name navigation + page navigation", () => {
+describe("Nested name navigation + page navigation", async function(){
let driver: AppiumDriver;
- before(async () => {
+ before(async function(){
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.resetApp();
});
- it("should find First", async () => {
+ it("should find First", async function(){
await assureFirstComponent(driver);
});
- it("should navigate to Second(1)/master", async () => {
+ it("should navigate to Second(1)/master", async function(){
await findAndClick(driver, "GO TO SECOND");
await assureSecondComponent(driver, 1)
await assureNestedMasterComponent(driver);
});
- it("should load nested named Master", async () => {
+ it("should load nested named Master", async function(){
await findAndClick(driver, "LOAD NESTED NAMED OUTLET");
await assureNamedNestedMasterComponent(driver);
});
- it("should navigate to nested named Master Detail/1", async () => {
+ it("should navigate to nested named Master Detail/1", async function(){
const navigationButton =
await driver.findElementByAutomationText("DETAIL-NAMED 1");
navigationButton.click();
@@ -222,7 +228,7 @@ describe("Nested name navigation + page navigation", () => {
await assureNamedNestedDetailComponent(driver, 1);
});
- it("should navigate back to Master and navigate to Detail/2", async () => {
+ it("should navigate back to Master and navigate to Detail/2", async function(){
let navigationButton =
await driver.findElementByAutomationText("BACK-NESTED");
navigationButton.click();
@@ -237,68 +243,71 @@ describe("Nested name navigation + page navigation", () => {
});
});
-describe("Shouldn't be able to navigate back on startup", () => {
+describe("Shouldn't be able to navigate back on startup", async function(){
let driver: AppiumDriver;
- before(async () => {
+ before(async function(){
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.resetApp();
});
- it("should find First", async () => {
+ it("should find First", async function(){
await assureFirstComponent(driver);
});
- it("shouldn't be able to go back", async () => {
+ it("shouldn't be able to go back", async function(){
await goBack(driver);
await driver.findElementByAutomationText("canGoBack() - false");
});
});
-describe("Shouldn't be able to navigate back after cleared history", () => {
+describe("Shouldn't be able to navigate back after cleared history", async function(){
let driver: AppiumDriver;
- before(async () => {
+ before(async function(){
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.resetApp();
});
- it("should find First", async () => {
+ it("should find First", async function(){
await assureFirstComponent(driver);
});
- it("should navigate to Second(1)/master", async () => {
+ it("should navigate to Second(1)/master", async function(){
await findAndClick(driver, "GO TO SECOND");
await assureSecondComponent(driver, 1)
await assureNestedMasterComponent(driver);
});
- it("should navigate to Second(1)/master", async () => {
+ it("should navigate to Second(1)/master", async function(){
await findAndClick(driver, "GO TO FIRST(CLEAR)");
await assureFirstComponent(driver);
});
- it("shouldn't be able to go back", async () => {
+ it("shouldn't be able to go back", async function(){
await goBack(driver);
await driver.findElementByAutomationText("canGoBack() - false");
});
});
-describe("Navigate to componentless route", () => {
+describe("Navigate to componentless route", async function(){
let driver: AppiumDriver;
- before(async () => {
+ before(async function(){
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.resetApp();
});
- it("should find First", async () => {
+ it("should find First", async function(){
await assureFirstComponent(driver);
});
- it("should navigate to ComponentlessSecond(100)/detail(200)", async () => {
+ it("should navigate to ComponentlessSecond(100)/detail(200)", async function(){
const navigationButton =
await driver.findElementByAutomationText("GO TO C-LESS SECOND");
navigationButton.click();
@@ -307,13 +316,13 @@ describe("Navigate to componentless route", () => {
await assureNestedDetailComponent(driver, 200);
});
- it("should navigate to First", async () => {
+ it("should navigate to First", async function(){
await findAndClick(driver, "GO TO FIRST");
await assureFirstComponent(driver);
});
- it("should navigate the whole stack", async () => {
+ it("should navigate the whole stack", async function(){
await goBack(driver);
await assureSecondComponent(driver, 100)
await assureNestedDetailComponent(driver, 200);
@@ -323,39 +332,40 @@ describe("Navigate to componentless route", () => {
});
});
-describe("Navigate to lazy module", () => {
+describe("Navigate to lazy module", async function(){
let driver: AppiumDriver;
- before(async () => {
+ before(async function(){
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.resetApp();
});
- it("should find First", async () => {
+ it("should find First", async function(){
await assureFirstComponent(driver);
});
- it("should navigate to lazy/home", async () => {
+ it("should navigate to lazy/home", async function(){
await findAndClick(driver, "GO TO LAZY HOME");
await assureLazyComponent(driver);
});
- it("should navigate to First", async () => {
+ it("should navigate to First", async function(){
await findAndClick(driver, "GO TO FIRST");
await assureFirstComponent(driver);
});
- it("should navigate back to lazy/home", async () => {
+ it("should navigate back to lazy/home", async function(){
await goBack(driver);
await assureLazyComponent(driver);
});
- it("should navigate to First again", async () => {
+ it("should navigate to First again", async function(){
await findAndClick(driver, "GO TO FIRST");
await assureFirstComponent(driver);
});
- it("should navigate the whole stack", async () => {
+ it("should navigate the whole stack", async function(){
await goBack(driver);
await assureLazyComponent(driver);
@@ -364,37 +374,38 @@ describe("Navigate to lazy module", () => {
});
});
-describe("Navigate to componentless lazy module route", () => {
+describe("Navigate to componentless lazy module route", async function(){
let driver: AppiumDriver;
- before(async () => {
+ before(async function(){
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.resetApp();
});
- it("should find First", async () => {
+ it("should find First", async function(){
await assureFirstComponent(driver);
});
- it("should navigate to nest/more (componentless lazy route)", async () => {
+ it("should navigate to nest/more (componentless lazy route)", async function(){
await findAndClick(driver, "GO TO C-LESS LAZY");
await assureComponentlessLazyComponent(driver);
});
- it("should navigate to lazy/home", async () => {
+ it("should navigate to lazy/home", async function(){
await findAndClick(driver, "GO TO LAZY HOME");
await assureLazyComponent(driver);
});
- it("should navigate to First", async () => {
+ it("should navigate to First", async function(){
await findAndClick(driver, "GO TO FIRST");
await assureFirstComponent(driver);
});
- it("should navigate the whole stack", async () => {
+ it("should navigate the whole stack", async function(){
await goBack(driver);
await assureLazyComponent(driver);
@@ -406,7 +417,39 @@ describe("Navigate to componentless lazy module route", () => {
});
});
-describe("Simple navigate and back should trigger only one CD on FirstComponent", () => {
+describe("Simple navigate and back should trigger only one CD on FirstComponent", async function(){
+ let driver: AppiumDriver;
+
+ before(async function(){
+ nsCapabilities.testReporter.context = this;
+ driver = await createDriver();
+ await driver.resetApp();
+ });
+
+ it("should find First", async function(){
+ await assureFirstComponent(driver);
+ });
+
+ it("should reset counter", async function(){
+ await findAndClick(driver, "RESET");
+ await driver.waitForElement("CHECK: 1");
+ });
+
+ it("should navigate to Second(1)/master", async function(){
+ await findAndClick(driver, "GO TO SECOND");
+
+ await assureSecondComponent(driver, 1);
+ await assureNestedMasterComponent(driver);
+ });
+
+ it("should navigate back to First", async function(){
+ await goBack(driver);
+ await assureFirstComponent(driver);
+ await driver.waitForElement("CHECK: 2");
+ });
+});
+
+describe("Simple navigate and back should trigger only one CD on FirstComponent even with 3 changes in service", () => {
let driver: AppiumDriver;
before(async () => {
@@ -421,6 +464,7 @@ describe("Simple navigate and back should trigger only one CD on FirstComponent"
it("should reset counter", async () => {
await findAndClick(driver, "RESET");
await driver.waitForElement("CHECK: 1");
+ await driver.waitForElement("COUNTER: 0");
});
it("should navigate to Second(1)/master", async () => {
@@ -430,13 +474,21 @@ describe("Simple navigate and back should trigger only one CD on FirstComponent"
await assureNestedMasterComponent(driver);
});
+ it("should increase counter", async () => {
+ await findAndClick(driver, "TICK");
+ await findAndClick(driver, "TICK");
+ await findAndClick(driver, "TICK");
+ });
+
it("should navigate back to First", async () => {
await goBack(driver);
await assureFirstComponent(driver);
await driver.waitForElement("CHECK: 2");
+ await driver.waitForElement("COUNTER: 3");
});
});
+
async function assureFirstComponent(driver: AppiumDriver) {
await driver.findElementByAutomationText("FirstComponent");
}
diff --git a/e2e/router/e2e/setup.ts b/e2e/router/e2e/setup.ts
index 0c0add14a..11b854fca 100644
--- a/e2e/router/e2e/setup.ts
+++ b/e2e/router/e2e/setup.ts
@@ -1,19 +1,19 @@
-import { startServer, stopServer , createDriver , AppiumDriver } from "nativescript-dev-appium";
+import { startServer, stopServer, ITestReporter, nsCapabilities, LogImageType } from "nativescript-dev-appium";
+const addContext = require('mochawesome/addContext');
-let driver: AppiumDriver;
+const testReporterContext = {};
+testReporterContext.name = "mochawesome";
+testReporterContext.reportDir = "mochawesome-report";
+testReporterContext.log = addContext;
+testReporterContext.logImageTypes = [LogImageType.screenshots];
+nsCapabilities.testReporter = testReporterContext;
-before("start server", async () => {
+before("start server", async function () {
+ nsCapabilities.testReporter.context = this;
await startServer();
- driver = await createDriver();
});
-after("stop server", async () => {
- await driver.quit();
+after("stop server", async function () {
+ nsCapabilities.testReporter.context = this;
await stopServer();
});
-
-afterEach(async function () {
- if (this.currentTest.state === "failed") {
- await driver.logScreenshot(this.currentTest.title);
- }
-});
\ No newline at end of file
diff --git a/e2e/router/package.json b/e2e/router/package.json
index 0f38b6720..1e7340917 100644
--- a/e2e/router/package.json
+++ b/e2e/router/package.json
@@ -6,7 +6,7 @@
"nativescript": {
"id": "org.nativescript.router",
"tns-android": {
- "version": "5.1.0"
+ "version": "next"
}
},
"dependencies": {
@@ -35,18 +35,16 @@
"babel-traverse": "6.25.0",
"babel-types": "6.25.0",
"babylon": "6.17.4",
- "chai": "~4.1.1",
"chai-as-promised": "~7.1.1",
"colors": "^1.1.2",
"lazy": "1.0.11",
"mocha": "~5.2.0",
- "mocha-junit-reporter": "~1.18.0",
- "mocha-multi": "~1.0.1",
- "nativescript-dev-appium": "^4.0.10-2019-01-16-01",
- "nativescript-dev-typescript": "^0.7.10-next-2019-01-07-183215-03",
+ "mochawesome": "~3.1.2",
+ "nativescript-dev-appium": "next",
+ "nativescript-dev-typescript": "next",
"nativescript-dev-webpack": "next",
"tslib": "^1.7.1",
- "typescript": "^3.1.6"
+ "typescript": "~3.1.1"
},
"scripts": {
"e2e": "tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json",
diff --git a/e2e/single-page/.gitignore b/e2e/single-page/.gitignore
index 8e824499e..e3eb2283a 100644
--- a/e2e/single-page/.gitignore
+++ b/e2e/single-page/.gitignore
@@ -7,4 +7,5 @@ hooks
/**/*.js
/**/*.map
e2e/reports
-test-results.xml
\ No newline at end of file
+test-results.xml
+mochawesome-report
\ No newline at end of file
diff --git a/e2e/single-page/e2e/setup.ts b/e2e/single-page/e2e/setup.ts
index 0c0add14a..11b854fca 100644
--- a/e2e/single-page/e2e/setup.ts
+++ b/e2e/single-page/e2e/setup.ts
@@ -1,19 +1,19 @@
-import { startServer, stopServer , createDriver , AppiumDriver } from "nativescript-dev-appium";
+import { startServer, stopServer, ITestReporter, nsCapabilities, LogImageType } from "nativescript-dev-appium";
+const addContext = require('mochawesome/addContext');
-let driver: AppiumDriver;
+const testReporterContext = {};
+testReporterContext.name = "mochawesome";
+testReporterContext.reportDir = "mochawesome-report";
+testReporterContext.log = addContext;
+testReporterContext.logImageTypes = [LogImageType.screenshots];
+nsCapabilities.testReporter = testReporterContext;
-before("start server", async () => {
+before("start server", async function () {
+ nsCapabilities.testReporter.context = this;
await startServer();
- driver = await createDriver();
});
-after("stop server", async () => {
- await driver.quit();
+after("stop server", async function () {
+ nsCapabilities.testReporter.context = this;
await stopServer();
});
-
-afterEach(async function () {
- if (this.currentTest.state === "failed") {
- await driver.logScreenshot(this.currentTest.title);
- }
-});
\ No newline at end of file
diff --git a/e2e/single-page/e2e/tests.e2e-spec.ts b/e2e/single-page/e2e/tests.e2e-spec.ts
index 4a9857538..cf06732f1 100644
--- a/e2e/single-page/e2e/tests.e2e-spec.ts
+++ b/e2e/single-page/e2e/tests.e2e-spec.ts
@@ -1,16 +1,24 @@
import {
AppiumDriver,
createDriver,
+ nsCapabilities,
} from "nativescript-dev-appium";
-describe("Single page app", () => {
+describe("Single page app", async function () {
let driver: AppiumDriver;
- before(async () => {
+ before(async function () {
+ nsCapabilities.testReporter.context = this;
driver = await createDriver();
});
- it("should load first page", async () => {
+ afterEach(async function () {
+ if (this.currentTest.state === "failed") {
+ await driver.logTestArtifacts(this.currentTest.title);
+ }
+ });
+
+ it("should load first page", async function () {
await driver.findElementByAutomationText("First Component");
// ActionBar Title and item
@@ -18,7 +26,7 @@ describe("Single page app", () => {
await driver.findElementByAutomationText("ACTION1");
});
- it("should load second(1) page", async () => {
+ it("should load second(1) page", async function () {
await findAndClick(driver, "SECOND(1)");
await driver.findElementByAutomationText("Second Component: 1");
@@ -28,7 +36,7 @@ describe("Single page app", () => {
await driver.findElementByAutomationText("ACTION2");
});
- it("should load second(2) page", async () => {
+ it("should load second(2) page", async function () {
await findAndClick(driver, "SECOND(2)");
await driver.findElementByAutomationText("Second Component: 2");
@@ -39,7 +47,7 @@ describe("Single page app", () => {
await driver.findElementByAutomationText("ADD");
});
- it("should open and close modal view", async () => {
+ it("should open and close modal view", async function () {
await findAndClick(driver, "Show Modal");
await driver.findElementByAutomationText("Welcome to modal");
@@ -48,7 +56,7 @@ describe("Single page app", () => {
await driver.findElementByAutomationText("Second Component: 2");
});
- it("should go back to second(1) and first", async () => {
+ it("should go back to second(1) and first", async function () {
await findAndClick(driver, "Back");
await driver.findElementByAutomationText("Second Component: 1");
await findAndClick(driver, "Back");
diff --git a/e2e/single-page/package.json b/e2e/single-page/package.json
index c324e1e25..812376667 100644
--- a/e2e/single-page/package.json
+++ b/e2e/single-page/package.json
@@ -6,10 +6,10 @@
"nativescript": {
"id": "org.nativescript.singlepage",
"tns-ios": {
- "version": "4.0.1-2018-03-26-01"
+ "version": "next"
},
"tns-android": {
- "version": "4.0.0-2018.3.22.2"
+ "version": "next"
}
},
"dependencies": {
@@ -32,19 +32,17 @@
"devDependencies": {
"@angular/compiler-cli": "~7.2.0",
"@ngtools/webpack": "~7.2.0",
- "@types/chai": "^4.0.2",
- "@types/mocha": "^5.2.5",
- "@types/node": "^10.12.12",
+ "@types/chai": "~4.1.7",
+ "@types/mocha": "~5.2.5",
+ "@types/node": "~10.12.18",
"babel-traverse": "6.25.0",
"babel-types": "6.25.0",
"babylon": "6.17.4",
- "chai": "~4.1.1",
"chai-as-promised": "~7.1.1",
"colors": "^1.1.2",
"lazy": "1.0.11",
- "mocha": "~3.5.0",
- "mocha-junit-reporter": "^1.13.0",
- "mocha-multi": "^0.11.0",
+ "mocha": "~5.2.0",
+ "mochawesome": "~3.1.2",
"nativescript-dev-appium": "next",
"nativescript-dev-typescript": "next",
"nativescript-dev-webpack": "next",
diff --git a/merge-guidance-schema.png b/merge-guidance-schema.png
new file mode 100644
index 000000000..dd882471e
Binary files /dev/null and b/merge-guidance-schema.png differ
diff --git a/nativescript-angular/directives/dialogs.ts b/nativescript-angular/directives/dialogs.ts
index 7c8b45739..51363c032 100644
--- a/nativescript-angular/directives/dialogs.ts
+++ b/nativescript-angular/directives/dialogs.ts
@@ -6,7 +6,7 @@ import {
NgModuleRef,
ReflectiveInjector,
Type,
- ViewContainerRef,
+ ViewContainerRef
} from "@angular/core";
import { NSLocationStrategy } from "../router/ns-location-strategy";
@@ -18,14 +18,15 @@ import { DetachedLoader } from "../common/detached-loader";
import { PageFactory, PAGE_FACTORY } from "../platform-providers";
import { once } from "../common/utils";
import { topmost, Frame } from "tns-core-modules/ui/frame";
+import { ShowModalOptions } from "tns-core-modules/ui/core/view";
-export interface ModalDialogOptions {
+export type BaseShowModalOptions = Pick>;
+
+export interface ModalDialogOptions extends BaseShowModalOptions {
context?: any;
- fullscreen?: boolean;
- animated?: boolean;
- stretched?: boolean;
viewContainerRef?: ViewContainerRef;
moduleRef?: NgModuleRef;
+ target?: View;
}
export class ModalDialogParams {
@@ -35,13 +36,10 @@ export class ModalDialogParams {
}
}
-interface ShowDialogOptions {
+interface ShowDialogOptions extends BaseShowModalOptions {
containerRef: ViewContainerRef;
context: any;
doneCallback;
- fullscreen: boolean;
- animated: boolean;
- stretched: boolean;
pageFactory: PageFactory;
parentView: ViewBase;
resolver: ComponentFactoryResolver;
@@ -54,16 +52,20 @@ export class ModalDialogService {
}
public showModal(type: Type,
- { viewContainerRef, moduleRef, context, fullscreen, animated, stretched }: ModalDialogOptions
+ options: ModalDialogOptions
): Promise {
- if (!viewContainerRef) {
+ if (!options.viewContainerRef) {
throw new Error(
"No viewContainerRef: " +
"Make sure you pass viewContainerRef in ModalDialogOptions."
);
}
- let parentView = viewContainerRef.element.nativeElement;
+ let parentView = options.viewContainerRef.element.nativeElement;
+ if (options.target) {
+ parentView = options.target;
+ }
+
if (parentView instanceof AppHostView && parentView.ngAppRoot) {
parentView = parentView.ngAppRoot;
}
@@ -75,11 +77,11 @@ export class ModalDialogService {
parentView = parentView._ngDialogRoot;
}
- const pageFactory: PageFactory = viewContainerRef.injector.get(PAGE_FACTORY);
+ const pageFactory: PageFactory = options.viewContainerRef.injector.get(PAGE_FACTORY);
// resolve from particular module (moduleRef)
// or from same module as parentView (viewContainerRef)
- const componentContainer = moduleRef || viewContainerRef;
+ const componentContainer = options.moduleRef || options.viewContainerRef;
const resolver = componentContainer.injector.get(ComponentFactoryResolver);
let frame = parentView;
@@ -93,16 +95,14 @@ export class ModalDialogService {
setTimeout(() => {
try {
this._showDialog({
- containerRef: viewContainerRef,
- context,
+ ...options,
+ containerRef: options.viewContainerRef,
+ context: options.context,
doneCallback: resolve,
- fullscreen,
- animated,
- stretched,
pageFactory,
parentView,
resolver,
- type,
+ type
});
} catch (err) {
reject(err);
@@ -111,23 +111,12 @@ export class ModalDialogService {
});
}
- private _showDialog({
- containerRef,
- context,
- doneCallback,
- fullscreen,
- animated,
- stretched,
- pageFactory,
- parentView,
- resolver,
- type,
- }: ShowDialogOptions): void {
+ private _showDialog(options: ShowDialogOptions): void {
let componentView: View;
let detachedLoaderRef: ComponentRef;
const closeCallback = once((...args) => {
- doneCallback.apply(undefined, args);
+ options.doneCallback.apply(undefined, args);
if (componentView) {
componentView.closeModal();
this.location._closeModalNavigation();
@@ -136,15 +125,15 @@ export class ModalDialogService {
}
});
- const modalParams = new ModalDialogParams(context, closeCallback);
+ const modalParams = new ModalDialogParams(options.context, closeCallback);
const providers = ReflectiveInjector.resolve([
{ provide: ModalDialogParams, useValue: modalParams },
]);
- const childInjector = ReflectiveInjector.fromResolvedProviders(providers, containerRef.parentInjector);
- const detachedFactory = resolver.resolveComponentFactory(DetachedLoader);
- detachedLoaderRef = containerRef.createComponent(detachedFactory, -1, childInjector, null);
- detachedLoaderRef.instance.loadComponent(type).then((compRef) => {
+ const childInjector = ReflectiveInjector.fromResolvedProviders(providers, options.containerRef.parentInjector);
+ const detachedFactory = options.resolver.resolveComponentFactory(DetachedLoader);
+ detachedLoaderRef = options.containerRef.createComponent(detachedFactory, -1, childInjector, null);
+ detachedLoaderRef.instance.loadComponent(options.type).then((compRef) => {
const detachedProxy = compRef.location.nativeElement;
if (detachedProxy.getChildrenCount() > 1) {
@@ -157,9 +146,7 @@ export class ModalDialogService {
(componentView.parent).removeChild(componentView);
}
- // TODO: remove cast after https://github.com/NativeScript/NativeScript/pull/5734
- // is in a published version of tns-core-modules.
- (parentView).showModal(componentView, context, closeCallback, fullscreen, animated, stretched);
+ options.parentView.showModal(componentView, { ...options, closeCallback });
});
}
}
diff --git a/nativescript-angular/directives/templated-items-comp.ts b/nativescript-angular/directives/templated-items-comp.ts
index f3644f071..a70746796 100644
--- a/nativescript-angular/directives/templated-items-comp.ts
+++ b/nativescript-angular/directives/templated-items-comp.ts
@@ -100,6 +100,11 @@ export abstract class TemplatedItemsComponent implements DoCheck, OnDestroy, Aft
ngOnDestroy() {
this.templatedItemsView.off("itemLoading", this.onItemLoading, this);
+ this.templatedItemsView = null;
+
+ if (this._templateMap) {
+ this._templateMap.clear();
+ }
}
private setItemTemplates() {
diff --git a/nativescript-angular/package.json b/nativescript-angular/package.json
index f63220905..b185a77f9 100644
--- a/nativescript-angular/package.json
+++ b/nativescript-angular/package.json
@@ -1,6 +1,6 @@
{
"name": "nativescript-angular",
- "version": "7.2.3",
+ "version": "7.2.4",
"description": "An Angular renderer that lets you build mobile apps with NativeScript.",
"homepage": "https://www.nativescript.org/",
"bugs": "https://github.com/NativeScript/nativescript-angular/issues",
@@ -34,7 +34,8 @@
"tsc-w": "tsc -p tsconfig.json -w",
"ngc": "ngc -p tsconfig.json",
"prepare": "npm run ngc",
- "version": "rm -rf package-lock.json && conventional-changelog -p angular -i ../CHANGELOG.md -s && git add ../CHANGELOG.md"
+ "version": "rm -rf package-lock.json && conventional-changelog -p angular -i ../CHANGELOG.md -s && git add ../CHANGELOG.md",
+ "typedoc": "typedoc --tsconfig \"./tsconfig.typedoc.json\" --out ./bin/dist/ng-api-reference --includeDeclarations --name \"NativeScript Angular\" --theme ./node_modules/nativescript-typedoc-theme --excludeExternals --externalPattern \"**/+(tns-core-modules|module|declarations).d.ts\""
},
"bin": {
"update-app-ng-deps": "./bin/update-app-ng-deps"
@@ -73,6 +74,8 @@
"tns-core-modules": "next",
"tslint": "^5.5.0",
"typescript": "~3.1.1",
- "zone.js": "^0.8.4"
+ "zone.js": "^0.8.4",
+ "nativescript-typedoc-theme": "git://github.com/NativeScript/nativescript-typedoc-theme.git#master",
+ "typedoc": "^0.13.0"
}
}
diff --git a/nativescript-angular/platform-common.ts b/nativescript-angular/platform-common.ts
index 2f7e958cd..d6a4c557f 100644
--- a/nativescript-angular/platform-common.ts
+++ b/nativescript-angular/platform-common.ts
@@ -33,6 +33,8 @@ import {
on,
launchEvent,
LaunchEventData,
+ exitEvent,
+ ApplicationEventData,
} from "tns-core-modules/application";
import { TextView } from "tns-core-modules/ui/text-view";
@@ -255,7 +257,29 @@ export class NativeScriptPlatformRef extends PlatformRef {
args.root = rootContent;
}
);
+ const exitCallback = profile(
+ "nativescript-angular/platform-common.exitCallback", (args: ApplicationEventData) => {
+ const androidActivity = args.android;
+ if (androidActivity && !androidActivity.isFinishing()) {
+ // Exit event was triggered as a part of a restart of the app.
+ return;
+ }
+
+ const lastModuleRef = lastBootstrappedModule ? lastBootstrappedModule.get() : null;
+ if (lastModuleRef) {
+ // Make sure the module is only destroyed once
+ lastBootstrappedModule = null;
+
+ lastModuleRef.destroy();
+ }
+
+ if (!autoCreateFrame) {
+ rootContent = null;
+ }
+ }
+ );
on(launchEvent, launchCallback);
+ on(exitEvent, exitCallback);
applicationRun();
}
diff --git a/nativescript-angular/renderer.ts b/nativescript-angular/renderer.ts
index ea6998cde..450c27f5d 100644
--- a/nativescript-angular/renderer.ts
+++ b/nativescript-angular/renderer.ts
@@ -73,6 +73,16 @@ export class NativeScriptRendererFactory implements RendererFactory2 {
this.componentRenderers.set(type.id, renderer);
return renderer;
}
+
+ ngOnDestroy(): void {
+ if (isLogEnabled()) {
+ traceLog(`NativeScriptRendererFactory.ngOnDestroy()`);
+ }
+
+ while (this.rootNgView && this.rootNgView.firstChild) {
+ this.viewUtil.removeChild(this.rootNgView, this.rootNgView.firstChild);
+ }
+ }
}
export class NativeScriptRenderer extends Renderer2 {
@@ -129,7 +139,7 @@ export class NativeScriptRenderer extends Renderer2 {
@profile
parentNode(node: NgView): any {
if (isLogEnabled()) {
- traceLog(`NativeScriptRenderer.parentNode for node: ${node}`);
+ traceLog(`NativeScriptRenderer.parentNode for node: ${node} is ${node.parentNode}`);
}
return node.parentNode;
}
diff --git a/nativescript-angular/router/ns-location-strategy.ts b/nativescript-angular/router/ns-location-strategy.ts
index 6eab73c06..58d4962d2 100644
--- a/nativescript-angular/router/ns-location-strategy.ts
+++ b/nativescript-angular/router/ns-location-strategy.ts
@@ -744,4 +744,13 @@ export class NSLocationStrategy extends LocationStrategy {
private getOutletKey(path: string, outletName: string): string {
return path ? path + "-" + outletName : outletName;
}
+
+ ngOnDestroy() {
+ if (isLogEnabled()) {
+ routerLog("NSLocationStrategy.ngOnDestroy()");
+ }
+
+ this.outlets = [];
+ this.currentOutlet = null;
+ }
}
diff --git a/nativescript-angular/router/ns-platform-location.ts b/nativescript-angular/router/ns-platform-location.ts
index 311faa5b8..ebd86f067 100644
--- a/nativescript-angular/router/ns-platform-location.ts
+++ b/nativescript-angular/router/ns-platform-location.ts
@@ -6,7 +6,7 @@ import { routerLog, isLogEnabled } from "../trace";
@Injectable()
export class NativescriptPlatformLocation extends PlatformLocation {
- constructor(private locationStartegy: NSLocationStrategy) {
+ constructor(private locationStrategy: NSLocationStrategy) {
super();
if (isLogEnabled()) {
routerLog("NativescriptPlatformLocation.constructor()");
@@ -18,7 +18,7 @@ export class NativescriptPlatformLocation extends PlatformLocation {
}
onPopState(fn: LocationChangeListener): void {
- this.locationStartegy.onPopState(fn);
+ this.locationStrategy.onPopState(fn);
}
onHashChange(_fn: LocationChangeListener): void {
@@ -31,18 +31,18 @@ export class NativescriptPlatformLocation extends PlatformLocation {
return "";
}
get pathname(): string {
- return this.locationStartegy.path();
+ return this.locationStrategy.path();
}
set pathname(_newPath: string) {
throw new Error("NativescriptPlatformLocation set pathname - not implemented");
}
pushState(state: any, title: string, url: string): void {
- this.locationStartegy.pushState(state, title, url, null);
+ this.locationStrategy.pushState(state, title, url, null);
}
replaceState(state: any, title: string, url: string): void {
- this.locationStartegy.replaceState(state, title, url, null);
+ this.locationStrategy.replaceState(state, title, url, null);
}
forward(): void {
@@ -50,6 +50,6 @@ export class NativescriptPlatformLocation extends PlatformLocation {
}
back(): void {
- this.locationStartegy.back();
+ this.locationStrategy.back();
}
}
diff --git a/nativescript-angular/router/page-router-outlet.ts b/nativescript-angular/router/page-router-outlet.ts
index fdcd5e2b1..34ba4446f 100644
--- a/nativescript-angular/router/page-router-outlet.ts
+++ b/nativescript-angular/router/page-router-outlet.ts
@@ -198,7 +198,16 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
});
this.locationStrategy.clearOutlet(this.frame);
} else {
- log("NSLocationStrategy.ngOnDestroy: no outlet available for page-router-outlet");
+ log("PageRouterOutlet.ngOnDestroy: no outlet available for page-router-outlet");
+ }
+
+ if (this.isActivated) {
+ const c = this.activated.instance;
+ this.activated.hostView.detach();
+ destroyComponentRef(this.activated);
+
+ this.deactivateEvents.emit(c);
+ this.activated = null;
}
}
@@ -262,6 +271,7 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
this.activated = ref;
// reattach to ChangeDetection
+ this.activated.hostView.markForCheck();
this.activated.hostView.reattach();
this._activatedRoute = activatedRoute;
this.markActivatedRoute(activatedRoute);
@@ -350,14 +360,21 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
// Remove it from original native parent.
this.viewUtil.removeChild(componentView.parent, componentView);
// Add it to the new page
- page.content = componentView;
+ this.viewUtil.insertChild(page, componentView);
- page.on(Page.navigatedFromEvent, (global).Zone.current.wrap((args: NavigatedData) => {
+ const navigatedFromCallback = (global).Zone.current.wrap((args: NavigatedData) => {
if (args.isBackNavigation) {
this.locationStrategy._beginBackPageNavigation(this.frame);
this.locationStrategy.back(null, this.frame);
}
- }));
+ });
+ page.on(Page.navigatedFromEvent, navigatedFromCallback);
+ componentRef.onDestroy(() => {
+ if (page) {
+ page.off(Page.navigatedFromEvent, navigatedFromCallback);
+ page = null;
+ }
+ });
const navOptions = this.locationStrategy._beginPageNavigation(this.frame);
@@ -367,14 +384,15 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
if (this.outlet) {
this.routeReuseStrategy.clearCache(this.outlet.outletKeys[0]);
}
- page.off(Page.navigatedToEvent, clearCallback);
});
- page.on(Page.navigatedToEvent, clearCallback);
+ page.once(Page.navigatedToEvent, clearCallback);
}
this.frame.navigate({
- create: () => { return page; },
+ create() {
+ return page;
+ },
clearHistory: navOptions.clearHistory,
animated: navOptions.animated,
transition: navOptions.transition
diff --git a/nativescript-angular/router/router.module.ts b/nativescript-angular/router/router.module.ts
index 385b4fe1f..5246eeea0 100644
--- a/nativescript-angular/router/router.module.ts
+++ b/nativescript-angular/router/router.module.ts
@@ -19,32 +19,39 @@ export { NSEmptyOutletComponent } from "./ns-empty-outlet.component";
export type LocationState = LocationState;
+const ROUTER_DIRECTIVES = [NSRouterLink, NSRouterLinkActive, PageRouterOutlet, NSEmptyOutletComponent];
+
+const NS_ROUTER_PROVIDERS = [
+ {
+ provide: NSLocationStrategy,
+ useFactory: provideLocationStrategy,
+ deps: [[NSLocationStrategy, new Optional(), new SkipSelf()], FrameService],
+ },
+ { provide: LocationStrategy, useExisting: NSLocationStrategy },
+ NativescriptPlatformLocation,
+ { provide: PlatformLocation, useExisting: NativescriptPlatformLocation },
+ RouterExtensions,
+ NSRouteReuseStrategy,
+ { provide: RouteReuseStrategy, useExisting: NSRouteReuseStrategy },
+];
+
@NgModule({
- declarations: [NSRouterLink, NSRouterLinkActive, PageRouterOutlet, NSEmptyOutletComponent],
- providers: [
- {
- provide: NSLocationStrategy,
- useFactory: provideLocationStrategy,
- deps: [[NSLocationStrategy, new Optional(), new SkipSelf()], FrameService],
- },
- { provide: LocationStrategy, useExisting: NSLocationStrategy },
- NativescriptPlatformLocation,
- { provide: PlatformLocation, useClass: NativescriptPlatformLocation },
- RouterExtensions,
- NSRouteReuseStrategy,
- { provide: RouteReuseStrategy, useExisting: NSRouteReuseStrategy },
- ],
+ declarations: ROUTER_DIRECTIVES,
+ entryComponents: [NSEmptyOutletComponent],
imports: [RouterModule, NativeScriptCommonModule],
- exports: [RouterModule, NSRouterLink, NSRouterLinkActive, PageRouterOutlet, NSEmptyOutletComponent],
+ exports: [RouterModule, ...ROUTER_DIRECTIVES],
schemas: [NO_ERRORS_SCHEMA],
})
export class NativeScriptRouterModule {
- static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders {
- return RouterModule.forRoot(routes, config);
+ static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders {
+ return {
+ ngModule: NativeScriptRouterModule,
+ providers: [...RouterModule.forRoot(routes, config).providers, ...NS_ROUTER_PROVIDERS]
+ };
}
- static forChild(routes: Routes): ModuleWithProviders {
- return RouterModule.forChild(routes);
+ static forChild(routes: Routes): ModuleWithProviders {
+ return { ngModule: NativeScriptRouterModule, providers: RouterModule.forChild(routes).providers };
}
}
diff --git a/nativescript-angular/tsconfig.json b/nativescript-angular/tsconfig.json
index e05ddfed9..e8a09f283 100644
--- a/nativescript-angular/tsconfig.json
+++ b/nativescript-angular/tsconfig.json
@@ -16,14 +16,7 @@
"dom",
"es6",
"es2015.iterable"
- ],
- "baseUrl": ".",
- "paths": {
- "*": [
- "./node_modules/tns-core-modules/*",
- "./node_modules/*"
- ]
- }
+ ]
},
"angularCompilerOptions": {
"genDir": ".",
diff --git a/nativescript-angular/tsconfig.typedoc.json b/nativescript-angular/tsconfig.typedoc.json
new file mode 100644
index 000000000..3074c04b8
--- /dev/null
+++ b/nativescript-angular/tsconfig.typedoc.json
@@ -0,0 +1,61 @@
+{"compilerOptions": {
+ "target": "es5",
+ "module": "commonjs",
+ "moduleResolution": "node",
+ "sourceMap": true,
+ "emitDecoratorMetadata": true,
+ "experimentalDecorators": true,
+ "noImplicitUseStrict": true,
+ "noEmitHelpers": true,
+ "declaration": true,
+ "removeComments": false,
+ "noEmitOnError": true,
+ "noImplicitAny": false,
+ "lib": [
+ "dom",
+ "es6",
+ "es2015.iterable"
+ ],
+ "baseUrl": ".",
+ "paths": {
+ "*": [
+ "./node_modules/tns-core-modules/*",
+ "./node_modules/*"
+ ]
+ }
+ },
+ "angularCompilerOptions": {
+ "genDir": ".",
+ "skipMetadataEmit": false,
+ "skipTemplateCodegen": true,
+ "strictMetadataEmit": true
+ },
+"exclude": [
+ "./node_modules",
+ "tns-core-modules/references.d.ts",
+ "tns-core-modules/node_modules",
+ "tns-core-modules/ui/frame/transition-definitions.android.d.ts",
+ "./zone-js",
+ "./index.ts",
+ "./bin",
+ "./index.d.ts",
+ "./testing",
+ "./animations/index.ts",
+ "./animations/utils.ts",
+ "./app-host-view.ts",
+ "./common/utils.ts",
+ "./dom-adapter.ts",
+ "./file-system",
+ "./forms/index.ts",
+ "./forms/value-accessors/index.ts",
+ "./lang-facade.ts",
+ "./polyfills",
+ "./router/private-imports",
+ "./schema-registry.ts",
+ "./http-client/index.ts",
+ "./http/index.ts",
+ "./router/index.ts",
+ ""
+
+ ]
+}
\ No newline at end of file
diff --git a/nativescript-angular/view-util.ts b/nativescript-angular/view-util.ts
index 5a3dea4c8..faeb62329 100644
--- a/nativescript-angular/view-util.ts
+++ b/nativescript-angular/view-util.ts
@@ -170,7 +170,9 @@ export class ViewUtil {
const extendedChild = this.ensureNgViewExtensions(child);
this.removeFromQueue(extendedParent, extendedChild);
- this.removeFromVisualTree(extendedParent, extendedChild);
+ if (!isDetachedElement(extendedChild)) {
+ this.removeFromVisualTree(extendedParent, extendedChild);
+ }
}
private removeFromQueue(parent: NgView, child: NgView) {
@@ -181,6 +183,7 @@ export class ViewUtil {
if (parent.firstChild === child && parent.lastChild === child) {
parent.firstChild = null;
parent.lastChild = null;
+ child.nextSibling = null;
return;
}
@@ -196,6 +199,8 @@ export class ViewUtil {
if (previous) {
previous.nextSibling = child.nextSibling;
}
+
+ child.nextSibling = null;
}
// NOTE: This one is O(n) - use carefully
@@ -240,7 +245,7 @@ export class ViewUtil {
private removeFromVisualTree(parent: NgView, child: NgView) {
if (isLogEnabled()) {
- traceLog(`ViewUtil.findPreviousElement parent: ${parent} child: ${child}`);
+ traceLog(`ViewUtil.removeFromVisualTree parent: ${parent} child: ${child}`);
}
if (parent.meta && parent.meta.removeChild) {
@@ -249,8 +254,6 @@ export class ViewUtil {
this.removeLayoutChild(parent, child);
} else if (isContentView(parent) && parent.content === child) {
parent.content = null;
- parent.lastChild = null;
- parent.firstChild = null;
} else if (isView(parent)) {
parent._removeView(child);
}
@@ -273,14 +276,15 @@ export class ViewUtil {
}
public createView(name: string): NgView {
- if (isLogEnabled()) {
- traceLog(`Creating view: ${name}`);
- }
-
+ const originalName = name;
if (!isKnownView(name)) {
name = "ProxyViewContainer";
}
+ if (isLogEnabled()) {
+ traceLog(`Creating view: ${originalName} ${name}`);
+ }
+
const viewClass = getViewClass(name);
const view = new viewClass();
const ngView = this.setNgViewExtensions(view, name);
@@ -300,6 +304,10 @@ export class ViewUtil {
}
private setNgViewExtensions(view: View, name: string): NgView {
+ if (isLogEnabled()) {
+ traceLog(`Make into a NgView view: ${view} name: "${name}"`);
+ }
+
const ngView = view as NgView;
ngView.nodeName = name;
ngView.meta = getViewMeta(name);
diff --git a/release-contribution-guide-schema-webpack.png b/release-contribution-guide-schema-webpack.png
new file mode 100644
index 000000000..fa8066082
Binary files /dev/null and b/release-contribution-guide-schema-webpack.png differ
diff --git a/tests/app/tests/router-module-tests.ts b/tests/app/tests/router-module-tests.ts
new file mode 100644
index 000000000..7bce3f7ef
--- /dev/null
+++ b/tests/app/tests/router-module-tests.ts
@@ -0,0 +1,74 @@
+// make sure you import mocha-config before @angular/core
+import { Component, ViewChild } from "@angular/core";
+import { nsTestBedAfterEach, nsTestBedBeforeEach, nsTestBedRender } from "nativescript-angular/testing";
+import { NativeScriptRouterModule, RouterExtensions } from "nativescript-angular/router";
+import { NSRouterLink } from "nativescript-angular/router/ns-router-link";
+import { NSLocationStrategy } from "nativescript-angular/router/ns-location-strategy";
+import { assert } from "~/tests/test-config";
+import { ActivatedRoute, Router, RouteReuseStrategy } from "@angular/router";
+import { LocationStrategy, PlatformLocation } from "@angular/common";
+import { NSRouteReuseStrategy } from "nativescript-angular/router/ns-route-reuse-strategy";
+
+@Component({
+ template: ``
+})
+class RouterTestComponent {
+ @ViewChild(NSRouterLink)
+ nsRouterLink: NSRouterLink;
+}
+
+describe("NativeScriptRouterModule.forRoot", () => {
+ beforeEach(nsTestBedBeforeEach(
+ [RouterTestComponent],
+ [],
+ [NativeScriptRouterModule.forRoot([])],
+ []));
+
+ afterEach(nsTestBedAfterEach());
+
+ it("should provide nativescript routing services", () => {
+ return nsTestBedRender(RouterTestComponent).then((fixture) => {
+ const injector = fixture.componentRef.injector
+
+ assert.instanceOf(injector.get(LocationStrategy, null), NSLocationStrategy);
+ assert.instanceOf(injector.get(RouterExtensions, null), RouterExtensions);
+ assert.instanceOf(injector.get(RouteReuseStrategy, null), NSRouteReuseStrategy);
+ });
+ });
+
+ it("should provide nativescript routing directives", () => {
+ return nsTestBedRender(RouterTestComponent).then((fixture) => {
+ const linkDirective = fixture.componentRef.instance.nsRouterLink;
+ assert.instanceOf(linkDirective, NSRouterLink);
+ });
+ });
+});
+
+describe("NativeScriptRouterModule.forChild", () => {
+ beforeEach(nsTestBedBeforeEach(
+ [RouterTestComponent],
+ [
+ { provide: Router, useValue: {} },
+ { provide: RouterExtensions, useValue: {} },
+ { provide: ActivatedRoute, useValue: {} },
+ ],
+ [NativeScriptRouterModule.forChild([])],
+ []));
+ afterEach(nsTestBedAfterEach());
+
+ it("should not provide nativescript routing services", () => {
+ return nsTestBedRender(RouterTestComponent).then((fixture) => {
+ const injector = fixture.componentRef.injector
+ assert.isNull(injector.get(LocationStrategy, null));
+ assert.isNull(injector.get(RouteReuseStrategy, null));
+ });
+ });
+
+ it("should provide nativescript routing directives", () => {
+ return nsTestBedRender(RouterTestComponent).then((fixture) => {
+ const linkDirective = fixture.componentRef.instance.nsRouterLink;
+ assert.instanceOf(linkDirective, NSRouterLink);
+ });
+ });
+});
+