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
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
### Features
4
4
5
5
-`[jest-config]` Add `defineConfig` and `mergeConfig` helpers for type-safe Jest config ([#15844](https://github.com/jestjs/jest/pull/15844))
6
+
-`[jest-fake-timers]` Add `setTimerTickMode` to configure how timers advance
6
7
7
8
### Fixes
8
9
@@ -13,6 +14,7 @@
13
14
### Chore & Maintenance
14
15
15
16
-`[docs]` Update V30 migration guide to notify users on `jest.mock()` work with case-sensitive path ([#15849](https://github.com/jestjs/jest/pull/15849))
Copy file name to clipboardExpand all lines: docs/JestObjectAPI.md
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1126,6 +1126,29 @@ This function is not available when using legacy fake timers implementation.
1126
1126
1127
1127
:::
1128
1128
1129
+
### `jest.setTimerTickMode(mode)`
1130
+
1131
+
Allows configuring how fake timers advance time.
1132
+
1133
+
Configuration options:
1134
+
1135
+
```ts
1136
+
typeTimerTickMode=
1137
+
| {mode:'manual'}
1138
+
| {mode:'nextAsync'}
1139
+
| {mode:'interval'; delta?:number};
1140
+
```
1141
+
1142
+
-`manual`: Timers do not advance without explicit, manual calls to the tick APIs (`jest.advanceTimersByTime(ms)`, `jest.runAllTimers()`, etc).
1143
+
-`nextAsync`: The clock will continuously break the event loop, then run the next timer until the mode changes.
1144
+
-`interval`: This is the same as specifying `advanceTimers: true` with an `advanceTimeDelta`. If the delta is not specified, 20 will be used by default.
1145
+
1146
+
:::info
1147
+
1148
+
This function is not available when using legacy fake timers implementation.
1149
+
1150
+
:::
1151
+
1129
1152
### `jest.getRealSystemTime()`
1130
1153
1131
1154
When mocking time, `Date.now()` will also be mocked. If you for some reason need access to the real current time, you can invoke this function.
0 commit comments