Jest: add timers
This commit is contained in:
parent
5483781d4f
commit
f533a52407
12
jest.md
12
jest.md
|
@ -115,6 +115,18 @@ expect(fn)
|
||||||
.toHaveBeenCalledWith(expect.stringMatching(regexp))
|
.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
|
## References
|
||||||
|
|
||||||
Based on Jest v19. <http://facebook.github.io/jest/>
|
Based on Jest v19. <http://facebook.github.io/jest/>
|
||||||
|
|
Loading…
Reference in New Issue