Skip to content

Commit 6553315

Browse files
committed
Simplify async tests
1 parent 241c340 commit 6553315

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

e2e/unit.spec.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ test('unit tests contain no errors', async ({ page }) => {
55

66
await page.content();
77
// on average 15-17 seconds
8-
await page.waitForTimeout(20000)
8+
await page.waitForTimeout(20000);
9+
//await page.screenshot({ path: 'errors-view.png' , fullPage: true });
910
// Expect a jasmine bar to contain 0 failures
1011
await expect(page.locator('.jasmine-overall-result')).toHaveText(/0 failures/);
12+
1113
});
1214

test/ng/intervalSpec.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,17 @@ describe("$interval", () => {
6464
}, 2);
6565
});
6666

67-
it("should NOT call $evalAsync or $digest if invokeApply is set to false", (done) => {
67+
it("should NOT call $evalAsync or $digest if invokeApply is set to false", async () => {
6868
const evalAsyncSpy = spyOn($rootScope, "$evalAsync").and.callThrough();
6969
const digestSpy = spyOn($rootScope, "$digest").and.callThrough();
7070
const notifySpy = jasmine.createSpy("notify");
7171

7272
$interval(notifySpy, 1, 1, false);
7373

74-
setTimeout(() => {
75-
expect(notifySpy).toHaveBeenCalled();
76-
expect(evalAsyncSpy).not.toHaveBeenCalled();
77-
expect(digestSpy).not.toHaveBeenCalled();
78-
done();
79-
}, 3);
74+
await wait(10);
75+
expect(notifySpy).toHaveBeenCalled();
76+
expect(evalAsyncSpy).not.toHaveBeenCalled();
77+
expect(digestSpy).not.toHaveBeenCalled();
8078
});
8179

8280
it("should allow you to specify a number of iterations", async () => {
@@ -139,10 +137,10 @@ describe("$interval", () => {
139137
expect(log).toEqual([]);
140138

141139
await wait(5);
142-
expect(log[0]).toEqual( "tick");
143-
expect(log[1]).toEqual( "promise update: 0");
144-
expect(log[2]).toEqual( "tick");
145-
expect(log[3]).toEqual( "promise update: 1");
140+
expect(log[0]).toEqual("tick");
141+
expect(log[1]).toEqual("promise update: 0");
142+
expect(log[2]).toEqual("tick");
143+
expect(log[3]).toEqual("promise update: 1");
146144
});
147145

148146
it("should return a promise which will be resolved after the specified number of iterations", async () => {

0 commit comments

Comments
 (0)