Skip to content

Commit 596bf4c

Browse files
Merge pull request #1808 from NativeScript/svetoslavtsenov/mochawesome-reporter-fixes
tests: replace anonymous functions
2 parents 015853a + b37ba3b commit 596bf4c

File tree

6 files changed

+26
-29
lines changed

6 files changed

+26
-29
lines changed

Diff for: e2e/modal-navigation-ng/e2e/modal.shared.e2e-spec.ts

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ describe("modal-shared:", async function () {
2424
await screen[root]();
2525
});
2626

27-
beforeEach(async function () {
28-
});
29-
3027
afterEach(async function () {
3128
if (this.currentTest.state === "failed") {
3229
await driver.logTestArtifacts(this.currentTest.title);

Diff for: e2e/nested-router-tab-view/e2e/tab-view.e2e-spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ describe("tab-view:", async function () {
1111
let driver: AppiumDriver;
1212
let screen: Screen;
1313

14-
before(async () => {
14+
before(async function () {
1515
nsCapabilities.testReporter.context = this;
1616
driver = await createDriver();
1717
screen = new Screen(driver);
1818
});
1919

20-
after(async () => {
20+
after(async function () {
2121
await driver.quit();
2222
console.log("Quit driver!");
2323
});
@@ -28,14 +28,14 @@ describe("tab-view:", async function () {
2828
}
2929
});
3030

31-
it("loaded home component and lists", async () => {
31+
it("loaded home component and lists", async function () {
3232
await screen.navigateToHomePage();
3333
await screen.loadedHome();
3434
await screen.loadedPlayersList();
3535
await screen.loadedTeamList();
3636
});
3737

38-
it("loaded tabs component, Players List and Teams List pages", async () => {
38+
it("loaded tabs component, Players List and Teams List pages", async function () {
3939
await screen.navigateToTabsPage();
4040
await screen.loadedTabs();
4141
await screen.loadedPlayersList();
@@ -45,7 +45,7 @@ describe("tab-view:", async function () {
4545
await screen.loadedPlayersList();
4646
});
4747

48-
it("should navigate Player One/Team One then back separately", async () => {
48+
it("should navigate Player One/Team One then back separately", async function () {
4949
await testPlayerNavigated(screen, screen.playerOne);
5050
await gotoTeamsTab(driver);
5151
await testTeamNavigated(screen, screen.teamOne);
@@ -56,7 +56,7 @@ describe("tab-view:", async function () {
5656
await screen.loadedPlayersList();
5757
});
5858

59-
it("should navigate Player One/Team One then next Player/Team then back", async () => {
59+
it("should navigate Player One/Team One then next Player/Team then back", async function () {
6060
await testPlayerNavigated(screen, screen.playerOne);
6161
await testPlayerNextNavigated(screen, screen.playerTwo);
6262
await gotoTeamsTab(driver);

Diff for: e2e/renderer/e2e/action-bar.e2e-spec.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe("Action Bar scenario", async function () {
1818
let toggleFirstButton: UIElement;
1919
let toggleSecondButton: UIElement;
2020

21-
before(async () => {
21+
before(async function () {
2222
nsCapabilities.testReporter.context = this;
2323
driver = await createDriver();
2424
await driver.driver.resetApp();
@@ -52,7 +52,7 @@ describe("Action Bar scenario", async function () {
5252
});
5353

5454
it("should detach first element when its condition is false", done => {
55-
(async () => {
55+
(async function () {
5656
await toggleFirst();
5757

5858
try {
@@ -69,7 +69,7 @@ describe("Action Bar scenario", async function () {
6969
});
7070

7171
it("should detach second element when its condition is false", done => {
72-
(async () => {
72+
(async function () {
7373
await toggleSecond();
7474

7575
try {
@@ -95,15 +95,15 @@ describe("Action Bar scenario", async function () {
9595
await checkOrderIsCorrect();
9696
});
9797

98-
const checkOrderIsCorrect = async () => {
98+
const checkOrderIsCorrect = async function () {
9999
await isOnTheLeft(firstActionItem, secondActionItem);
100100
};
101101

102-
const toggleFirst = async () => {
102+
const toggleFirst = async function () {
103103
await toggleFirstButton.click();
104104
};
105105

106-
const toggleSecond = async () => {
106+
const toggleSecond = async function () {
107107
await toggleSecondButton.click();
108108
};
109109

@@ -113,7 +113,7 @@ describe("Action Bar scenario", async function () {
113113
let toggleButton: UIElement;
114114
let conditional: UIElement;
115115

116-
before(async () => {
116+
before(async function () {
117117
nsCapabilities.testReporter.context = this;
118118
driver = await createDriver();
119119
await driver.driver.resetApp();
@@ -147,11 +147,11 @@ describe("Action Bar scenario", async function () {
147147
await checkOrderIsCorrect();
148148
});
149149

150-
const checkOrderIsCorrect = async () => {
150+
const checkOrderIsCorrect = async function () {
151151
await isOnTheLeft(toggleButton, conditional);
152152
};
153153

154-
const toggle = async () => {
154+
const toggle = async function () {
155155
await toggleButton.click();
156156
};
157157
});

Diff for: e2e/renderer/e2e/ngfor.e2e-spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("ngFor scenario", async function () {
1515
let elements: UIElement[] = [];
1616
let lastAddedElementId = 0;
1717

18-
before(async () => {
18+
before(async function () {
1919
nsCapabilities.testReporter.context = this;
2020
driver = await createDriver();
2121
await driver.driver.resetApp();
@@ -79,7 +79,7 @@ describe("ngFor scenario", async function () {
7979
await checkCorrectOrderAll();
8080
});
8181

82-
const addElement = async () => {
82+
const addElement = async function () {
8383
await addButton.click();
8484

8585
lastAddedElementId += 1;
@@ -103,7 +103,7 @@ describe("ngFor scenario", async function () {
103103
lastAddedElementId -= 1;
104104
};
105105

106-
const checkAppendedCorrectly = async () => {
106+
const checkAppendedCorrectly = async function () {
107107
const lastAdded = await driver.findElementByAutomationText(
108108
lastAddedElementId.toString());
109109

@@ -112,7 +112,7 @@ describe("ngFor scenario", async function () {
112112
await isAbove(addButton, removeButton);
113113
};
114114

115-
const checkCorrectOrderAll = async () => {
115+
const checkCorrectOrderAll = async function () {
116116
for (let i = 0; i < elements.length - 1; i += 1) {
117117
await isAbove(elements[i], elements[i + 1]);
118118
}

Diff for: e2e/renderer/e2e/ngforof.e2e-spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe("ngForOf scenario", function () {
2121
let elements: ElementTuple[] = [];
2222
let lastAddedElementId = 0;
2323

24-
before(async () => {
24+
before(async function () {
2525
nsCapabilities.testReporter.context = this;
2626
driver = await createDriver();
2727
await driver.driver.resetApp();
@@ -88,7 +88,7 @@ describe("ngForOf scenario", function () {
8888
});
8989

9090

91-
const addElement = async () => {
91+
const addElement = async function () {
9292
await addButton.click();
9393

9494
lastAddedElementId += 1;
@@ -114,15 +114,15 @@ describe("ngForOf scenario", function () {
114114
lastAddedElementId -= 1;
115115
};
116116

117-
const checkAppendedCorrectly = async () => {
117+
const checkAppendedCorrectly = async function () {
118118
const lastAdded = await getElement(lastAddedElementId);
119119

120120
await elementIsAbove(elements.slice(-2)[0], lastAdded);
121121
await isAbove(lastAdded.button, addButton);
122122
await isAbove(addButton, removeButton);
123123
};
124124

125-
const checkCorrectOrderAll = async () => {
125+
const checkCorrectOrderAll = async function () {
126126
for (let i = 0; i < elements.length - 1; i += 1) {
127127
await elementIsAbove(elements[i], elements[i + 1]);
128128
}

Diff for: e2e/renderer/e2e/ngif.e2e-spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { isAbove } from "./helpers/location";
1010

1111
import { assert } from "chai";
1212

13-
describe("ngIf scenario", () => {
13+
describe("ngIf scenario", async function () {
1414
let driver: AppiumDriver;
1515
let toggleButton: UIElement;
1616

@@ -376,7 +376,7 @@ describe("ngIf scenario", () => {
376376

377377
driver.findElementByAutomationText("first", 500)
378378
.then(_ => { throw new Error("first label found!"); })
379-
.catch(() => {
379+
.catch(async function () {
380380
driver.findElementByAutomationText("second", 500)
381381
.then(_ => { throw new Error("second label found!"); })
382382
.catch(() => done());
@@ -402,7 +402,7 @@ describe("ngIf scenario", () => {
402402

403403
driver.findElementByAutomationText("first", 500)
404404
.then(_ => { throw new Error("first label found!"); })
405-
.catch(() => {
405+
.catch(async function () {
406406
driver.findElementByAutomationText("second", 500)
407407
.then(_ => { throw new Error("second label found!"); })
408408
.catch(() => done());

0 commit comments

Comments
 (0)