You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@
11
11
-`[jest-message-util]` Add support for [AggregateError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError) ([#13946](https://github.com/facebook/jest/pull/13946) & [#13947](https://github.com/facebook/jest/pull/13947))
12
12
-`[jest-message-util]` Add support for [Error causes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause) in `test` and `it` ([#13935](https://github.com/facebook/jest/pull/13935) & [#13966](https://github.com/facebook/jest/pull/13966))
13
13
-`[jest-reporters]` Add `summaryThreshold` option to summary reporter to allow overriding the internal threshold that is used to print the summary of all failed tests when the number of test suites surpasses it ([#13895](https://github.com/facebook/jest/pull/13895))
-`[jest-runtime, @jest/transform]` Allow V8 coverage provider to collect coverage from files which were not loaded explicitly ([#13974](https://github.com/facebook/jest/pull/13974))
15
16
-`[jest-snapshot]` Add support to `cts` and `mts` TypeScript files to inline snapshots ([#13975](https://github.com/facebook/jest/pull/13975))
16
17
-`[jest-worker]` Add `start` method to worker farms ([#13937](https://github.com/facebook/jest/pull/13937))
Copy file name to clipboardExpand all lines: docs/JestObjectAPI.md
+40
Original file line number
Diff line number
Diff line change
@@ -921,6 +921,16 @@ When this API is called, all pending macro-tasks and micro-tasks will be execute
921
921
922
922
This is often useful for synchronously executing setTimeouts during a test in order to synchronously assert about some behavior that would only happen after the `setTimeout()` or `setInterval()` callbacks executed. See the [Timer mocks](TimerMocks.md) doc for more information.
923
923
924
+
### `jest.runAllTimersAsync()`
925
+
926
+
Asynchronous equivalent of `jest.runAllTimers()`. It allows any scheduled promise callbacks to execute _before_ running the timers.
927
+
928
+
:::info
929
+
930
+
This function is not available when using legacy fake timers implementation.
931
+
932
+
:::
933
+
924
934
### `jest.runAllImmediates()`
925
935
926
936
Exhausts all tasks queued by `setImmediate()`.
@@ -937,18 +947,48 @@ Executes only the macro task queue (i.e. all tasks queued by `setTimeout()` or `
937
947
938
948
When this API is called, all timers are advanced by `msToRun` milliseconds. All pending "macro-tasks" that have been queued via `setTimeout()` or `setInterval()`, and would be executed within this time frame will be executed. Additionally, if those macro-tasks schedule new macro-tasks that would be executed within the same time frame, those will be executed until there are no more macro-tasks remaining in the queue, that should be run within `msToRun` milliseconds.
939
949
950
+
### `jest.advanceTimersByTimeAsync(msToRun)`
951
+
952
+
Asynchronous equivalent of `jest.advanceTimersByTime(msToRun)`. It allows any scheduled promise callbacks to execute _before_ running the timers.
953
+
954
+
:::info
955
+
956
+
This function is not available when using legacy fake timers implementation.
957
+
958
+
:::
959
+
940
960
### `jest.runOnlyPendingTimers()`
941
961
942
962
Executes only the macro-tasks that are currently pending (i.e., only the tasks that have been queued by `setTimeout()` or `setInterval()` up to this point). If any of the currently pending macro-tasks schedule new macro-tasks, those new tasks will not be executed by this call.
943
963
944
964
This is useful for scenarios such as one where the module being tested schedules a `setTimeout()` whose callback schedules another `setTimeout()` recursively (meaning the scheduling never stops). In these scenarios, it's useful to be able to run forward in time by a single step at a time.
945
965
966
+
### `jest.runOnlyPendingTimersAsync()`
967
+
968
+
Asynchronous equivalent of `jest.runOnlyPendingTimers()`. It allows any scheduled promise callbacks to execute _before_ running the timers.
969
+
970
+
:::info
971
+
972
+
This function is not available when using legacy fake timers implementation.
973
+
974
+
:::
975
+
946
976
### `jest.advanceTimersToNextTimer(steps)`
947
977
948
978
Advances all timers by the needed milliseconds so that only the next timeouts/intervals will run.
949
979
950
980
Optionally, you can provide `steps`, so it will run `steps` amount of next timeouts/intervals.
951
981
982
+
### `jest.advanceTimersToNextTimerAsync(steps)`
983
+
984
+
Asynchronous equivalent of `jest.advanceTimersToNextTimer(steps)`. It allows any scheduled promise callbacks to execute _before_ running the timers.
985
+
986
+
:::info
987
+
988
+
This function is not available when using legacy fake timers implementation.
0 commit comments