How to Handle Time and Date

Learn how to use the clock to mock the passage of time.

We can use Jasmine’s clock to mock the passage of time. For example, if we have a function that runs after a timeout, we would have to wait for the function to finish before we can make an expectation about the result. We can use the Jasmine clock fake to fast-forward the system time to get the function to run. In the example below, we have a method that fetches data after three seconds.

Get hands-on with 1200+ tech skills courses.