Skip to content

Commit 231e440

Browse files
deokjinkimmarco-ippolito
authored andcommitted
doc: add missing supported timer values in timers.enable()
Some timer values such as `setImmediate` and `clearImmediate` are missed. And `milliseconds` which is argument of `timers.tick()` is optional and default is 1. Refs: #49534 (comment) PR-URL: #52969 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
1 parent f29e1e9 commit 231e440

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

doc/api/test.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -1938,7 +1938,8 @@ Enables timer mocking for the specified timers.
19381938
The currently supported timer values are `'setInterval'`, `'setTimeout'`, `'setImmediate'`,
19391939
and `'Date'`. **Default:** `['setInterval', 'setTimeout', 'setImmediate', 'Date']`.
19401940
If no array is provided, all time related APIs (`'setInterval'`, `'clearInterval'`,
1941-
`'setTimeout'`, `'clearTimeout'`, and `'Date'`) will be mocked by default.
1941+
`'setTimeout'`, `'clearTimeout'`, `'setImmediate'`, `'clearImmediate'`, and
1942+
`'Date'`) will be mocked by default.
19421943
* `now` {number | Date} An optional number or Date object representing the
19431944
initial time (in milliseconds) to use as the value
19441945
for `Date.now()`. **Default:** `0`.
@@ -1993,10 +1994,11 @@ mock.timers.enable({ apis: ['Date'], now: new Date() });
19931994

19941995
Alternatively, if you call `mock.timers.enable()` without any parameters:
19951996

1996-
All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, and `'clearTimeout'`)
1997-
will be mocked. The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout`
1998-
functions from `node:timers`, `node:timers/promises`,
1999-
and `globalThis` will be mocked. As well as the global `Date` object.
1997+
All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, `'clearTimeout'`,
1998+
`'setImmediate'`, and `'clearImmediate'`) will be mocked. The `setInterval`,
1999+
`clearInterval`, `setTimeout`, `clearTimeout`, `setImmediate`, and
2000+
`clearImmediate` functions from `node:timers`, `node:timers/promises`, and
2001+
`globalThis` will be mocked. As well as the global `Date` object.
20002002

20012003
### `timers.reset()`
20022004

@@ -2026,7 +2028,7 @@ mock.timers.reset();
20262028

20272029
Calls `timers.reset()`.
20282030

2029-
### `timers.tick(milliseconds)`
2031+
### `timers.tick([milliseconds])`
20302032

20312033
<!-- YAML
20322034
added:
@@ -2036,7 +2038,7 @@ added:
20362038
Advances time for all mocked timers.
20372039

20382040
* `milliseconds` {number} The amount of time, in milliseconds,
2039-
to advance the timers.
2041+
to advance the timers. **Default:** `1`.
20402042

20412043
**Note:** This diverges from how `setTimeout` in Node.js behaves and accepts
20422044
only positive numbers. In Node.js, `setTimeout` with negative numbers is

0 commit comments

Comments
 (0)