fakeAsync

export fakeAsync(fn: Function) : Function

exported from angular2/testing defined in angular2/src/testing/fake_async.ts (line 13)

Wraps a function to be executed in the fakeAsync zone:

If there are any pending timers at the end of the function, an exception will be thrown.

Example

describe('this test', () => { it('looks async but is synchronous', <any>fakeAsync((): void => { var flag = false; setTimeout(() => { flag = true; }, 100); expect(flag).toBe(false); tick(50); expect(flag).toBe(false); tick(50); expect(flag).toBe(true); })); });