FakeAsync class

A class that mocks out the passage of time within a Zone.

Test code can be passed as a callback to run, which causes it to be run in a Zone which fakes timer and microtask creation, such that they are run during calls to elapse which simulates the asynchronous passage of time.

The synchronous passage of time (as from blocking or expensive calls) can also be simulated using elapseBlocking.

Constructors

FakeAsync({DateTime initialTime })
Creates a FakeAsync. [...]

Properties

elapsed → Duration
The amount of fake time that's elapsed since this FakeAsync was created.
read-only
microtaskCount → int
The number of pending microtasks scheduled within a call to run or fakeAsync.
read-only
nonPeriodicTimerCount → int
The number of active non-periodic timers created within a call to run or fakeAsync.
read-only
periodicTimerCount → int
The number of active periodic timers created within a call to run or fakeAsync.
read-only
hashCode → int
The hash code for this object.
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

elapse(Duration duration) → void
Simulates the asynchronous passage of time. [...]
elapseBlocking(Duration duration) → void
Simulates the synchronous passage of time, resulting from blocking or expensive calls. [...]
flushMicrotasks() → void
Runs all pending microtasks scheduled within a call to run or fakeAsync until there are no more microtasks scheduled. [...]
flushTimers({Duration timeout, bool flushPeriodicTimers: true }) → void
Elapses time until there are no more active timers. [...]
getClock(DateTime initialTime) Clock
Returns a fake Clock whose time can is elapsed by calls to elapse and elapseBlocking. [...]
run<T>(T callback(FakeAsync self)) → T
Runs callback in a Zone where all asynchrony is controlled by this. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator.
inherited