Skip to content

Commit 77fd504

Browse files
deokjinkimtargos
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 <benjamingr@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
1 parent 602da2d commit 77fd504

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
@@ -1983,7 +1983,8 @@ Enables timer mocking for the specified timers.
19831983
The currently supported timer values are `'setInterval'`, `'setTimeout'`, `'setImmediate'`,
19841984
and `'Date'`. **Default:** `['setInterval', 'setTimeout', 'setImmediate', 'Date']`.
19851985
If no array is provided, all time related APIs (`'setInterval'`, `'clearInterval'`,
1986-
`'setTimeout'`, `'clearTimeout'`, and `'Date'`) will be mocked by default.
1986+
`'setTimeout'`, `'clearTimeout'`, `'setImmediate'`, `'clearImmediate'`, and
1987+
`'Date'`) will be mocked by default.
19871988
* `now` {number | Date} An optional number or Date object representing the
19881989
initial time (in milliseconds) to use as the value
19891990
for `Date.now()`. **Default:** `0`.
@@ -2038,10 +2039,11 @@ mock.timers.enable({ apis: ['Date'], now: new Date() });
20382039

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

2041-
All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, and `'clearTimeout'`)
2042-
will be mocked. The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout`
2043-
functions from `node:timers`, `node:timers/promises`,
2044-
and `globalThis` will be mocked. As well as the global `Date` object.
2042+
All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, `'clearTimeout'`,
2043+
`'setImmediate'`, and `'clearImmediate'`) will be mocked. The `setInterval`,
2044+
`clearInterval`, `setTimeout`, `clearTimeout`, `setImmediate`, and
2045+
`clearImmediate` functions from `node:timers`, `node:timers/promises`, and
2046+
`globalThis` will be mocked. As well as the global `Date` object.
20452047

20462048
### `timers.reset()`
20472049

@@ -2072,7 +2074,7 @@ mock.timers.reset();
20722074

20732075
Calls `timers.reset()`.
20742076

2075-
### `timers.tick(milliseconds)`
2077+
### `timers.tick([milliseconds])`
20762078

20772079
<!-- YAML
20782080
added:
@@ -2083,7 +2085,7 @@ added:
20832085
Advances time for all mocked timers.
20842086

20852087
* `milliseconds` {number} The amount of time, in milliseconds,
2086-
to advance the timers.
2088+
to advance the timers. **Default:** `1`.
20872089

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

0 commit comments

Comments
 (0)