TimeFixture
allows you to control when callbacks passed to window.setTimeout() and window.setInterval()
are executed.
Currently setInterval() is not fully supported. It only fires once instead of repeating.
timeMode property
There are two modes supported by the
TimeFixture
:
- 'NextStep' (default) - will automatically fire all timers at the end of each 'given, when or then' step
(including 'and' steps)
- 'Manual' - will stop the automatic-firing of timers on each 'given, when or then' step
passedBy property
When in 'Manual' mode, 'passedBy' is defined in milliseconds. Any function(s) registered to wait for a period less
than (or equal to) the stated 'passedBy' value are then executed in ascending time order.
Example using 'NextStep' mode (default):
given("time.timeMode = 'NextStep'")
and(...)
// All timed events fired for the 'and' step above
and(...)
// All timed events fired for the 'and' step above
when(...)
// All timed events set up in the "when" step are fired
then(...)
Example using 'Manual' mode:
given("time.timeMode = 'Manual'")
and(...)
when(...)
and("time.passedBy => 2000")
// timed events from the 'given' and 'when' steps set to execute 2 seconds in the future are fired
then(...)