From 975bda1663a98b073d7656086f276e3e2afa6017 Mon Sep 17 00:00:00 2001 From: knee-cola Date: Tue, 21 Nov 2017 17:33:35 +0100 Subject: [PATCH 1/2] added `advanceTimersByTime` metod previous name for this method was `runTimersToTime` - it was renamed in renamed in Jest 21.3.0+ --- types/jest/index.d.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index 1b8d137094..8e31b66fb2 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -145,10 +145,15 @@ declare namespace jest { */ function runOnlyPendingTimers(): typeof jest; /** - * Executes only the macro task queue (i.e. all tasks queued by setTimeout() - * or setInterval() and setImmediate()). + * (renamed in Jest 21.3.0+ - use `advanceTimersByTime` instead) Executes only the macro + * task queue (i.e. all tasks queued by setTimeout() or setInterval() and setImmediate()). */ function runTimersToTime(msToRun: number): typeof jest; + /** + * Explicitly supplies the mock object that the module system should return + * for the specified module. + */ + function advanceTimersByTime(msToRun: number): typeof jest; /** * Explicitly supplies the mock object that the module system should return * for the specified module. @@ -867,6 +872,7 @@ declare namespace jest { runAllTicks(): void; runAllTimers(): void; runTimersToTime(msToRun: number): void; + advanceTimersByTime(msToRun: number): void; runOnlyPendingTimers(): void; runWithRealTimers(callback: any): void; useFakeTimers(): void; From 03bca40577f214e676f262ee4e4ca1a9edf82a45 Mon Sep 17 00:00:00 2001 From: knee-cola Date: Wed, 22 Nov 2017 09:24:02 +0100 Subject: [PATCH 2/2] fixed comment for`advanceTimersByTime` method --- types/jest/index.d.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index 8e31b66fb2..4fb67be2fc 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -145,13 +145,14 @@ declare namespace jest { */ function runOnlyPendingTimers(): typeof jest; /** - * (renamed in Jest 21.3.0+ - use `advanceTimersByTime` instead) Executes only the macro + * (renamed to `advanceTimersByTime` in Jest 21.3.0+) Executes only the macro * task queue (i.e. all tasks queued by setTimeout() or setInterval() and setImmediate()). */ function runTimersToTime(msToRun: number): typeof jest; /** - * Explicitly supplies the mock object that the module system should return - * for the specified module. + * Advances all timers by msToRun milliseconds. All pending "macro-tasks" that have been + * queued via setTimeout() or setInterval(), and would be executed within this timeframe + * will be executed. */ function advanceTimersByTime(msToRun: number): typeof jest; /**