UNPKG

1.39 kBTypeScriptView Raw
1/**
2 * Clears out the shared fake async zone for a test.
3 * To be called in a global `beforeEach`.
4 *
5 * @experimental
6 */
7export declare function resetFakeAsyncZone(): void;
8/**
9 * Wraps a function to be executed in the fakeAsync zone:
10 * - microtasks are manually executed by calling `flushMicrotasks()`,
11 * - timers are synchronous, `tick()` simulates the asynchronous passage of time.
12 *
13 * If there are any pending timers at the end of the function, an exception will be thrown.
14 *
15 * Can be used to wrap inject() calls.
16 *
17 * ## Example
18 *
19 * {@example testing/ts/fake_async.ts region='basic'}
20 *
21 * @param fn
22 * @returns {Function} The function wrapped to be executed in the fakeAsync zone
23 *
24 * @experimental
25 */
26export declare function fakeAsync(fn: Function): (...args: any[]) => any;
27/**
28 * Simulates the asynchronous passage of time for the timers in the fakeAsync zone.
29 *
30 * The microtasks queue is drained at the very start of this function and after any timer callback
31 * has been executed.
32 *
33 * ## Example
34 *
35 * {@example testing/ts/fake_async.ts region='basic'}
36 *
37 * @experimental
38 */
39export declare function tick(millis?: number): void;
40/**
41 * Discard all remaining periodic tasks.
42 *
43 * @experimental
44 */
45export declare function discardPeriodicTasks(): void;
46/**
47 * Flush any pending microtasks.
48 *
49 * @experimental
50 */
51export declare function flushMicrotasks(): void;