From f533a524076336260759fc4675c346af3d2124b2 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Thu, 24 Aug 2017 05:18:38 +0800 Subject: [PATCH] Jest: add timers --- jest.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/jest.md b/jest.md index bb5450925..c67f41a65 100644 --- a/jest.md +++ b/jest.md @@ -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.