3

I have a unit test that use jasmin.clock.install

I have the following error using jest-cli 20.0.4

TypeError: jasmine.clock is not a function

What package should I have in order to have this line work in my unit test :

jasmine.clock().install();

I managed to make it work by downgrading to jest-cli 19.0.1. it would be nice to know the upgrade procedure.

Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204

1 Answers1

3

From the docs jasmine.clock().install(); is needed to mock out setTimeout calls. So this can be done in Jest by using jest.useFakeTimers();. Have a look at the docs on how to mock timer in Jest. Also have a look at the announcement of v20 to see why the Jasmine stuff does not work anymore

Andreas Köberle
  • 106,652
  • 57
  • 273
  • 297