Read more

Mocking time in Jasmine specs

Henning Koch
July 29, 2015Software engineer at makandra GmbH

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 control setTimeout and setInterval.
  • Using jasmine.clock().mockDate() you can mock new Date() (which returns the current time in Javascript)
Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

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 20:41)