Jest: add timers

This commit is contained in:
Rico Sta. Cruz 2017-08-24 05:18:38 +08:00
parent 5483781d4f
commit f533a52407
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 12 additions and 0 deletions

12
jest.md
View File

@ -115,6 +115,18 @@ expect(fn)
.toHaveBeenCalledWith(expect.stringMatching(regexp))
```
## [Timers](https://facebook.github.io/jest/docs/timer-mocks.html)
```js
jest.useFakeTimers()
it('works', () => {
jest.runOnlyPendingTimers()
jest.runTimersToTime(1000)
jest.runAllTimers()
})
```
## References
Based on Jest v19. <http://facebook.github.io/jest/>