December 2015
Intermediate to advanced
240 pages
4h 57m
English
For cases, when we need to use the setTimeout() or setInterval() functions of JavaScript in our tests: Jasmine provides a clock that can make use of these functions available.
jasmine.clock().install() installs a clock for our specs and jasmine.clock().uninstall() restores the original JavaScript timer functions. Jasmine clock helps us handle time-dependent code using these functions. Let's see the following examples to understand how these work.
Suppose we want to check if Alice, an employee, was available after an hour, we create a spy for the checkAvailabity() function for an employee object:
var employee; beforeEach(function() { employee = new Employee("Alice", 5, "Testing"); employee.checkAvailability = jasmine.createSpy("checkAvailability"); ...Read now
Unlock full access