The easiest way to freeze or travel through time in a Jasmine spec is to use the built-in
jasmine.clock()
Show archive.org snapshot
.
- After
jasmine.clock().install()
you can use it to controlsetTimeout
andsetInterval
. - Using
jasmine.clock().mockDate()
you can mocknew Date()
(which returns the current time in Javascript)
While you can use SinonJS Fake timers Show archive.org snapshot , using the built-in Jasmine clock will save you an extra dependency.
Posted by Henning Koch to makandra dev (2015-07-29 18:41)