Asynchronous Tests (fakeAsync, tick, async, waitForAsync)
Angular supports asynchronous testing.
fakeAsync Example
Section titled “fakeAsync Example”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();}));