Skip to content

Asynchronous Tests (fakeAsync, tick, async, waitForAsync)

Angular supports asynchronous testing.

import { fakeAsync, tick } from "@angular/core/testing";
it("should wait for async task", fakeAsync(() => {
let done = false;
setTimeout(() => {
done = true;
}, 1000);
tick(1000);
expect(done).toBeTrue();
}));