Skip to content

Commit 30a9c6e

Browse files
deokjinkimbmeck
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: nodejs#49534 (comment) PR-URL: nodejs#52969 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
1 parent b696f17 commit 30a9c6e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

doc/api/test.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,8 @@ Enables timer mocking for the specified timers.
19911991
The currently supported timer values are `'setInterval'`, `'setTimeout'`, `'setImmediate'`,
19921992
and `'Date'`. **Default:** `['setInterval', 'setTimeout', 'setImmediate', 'Date']`.
19931993
If no array is provided, all time related APIs (`'setInterval'`, `'clearInterval'`,
1994-
`'setTimeout'`, `'clearTimeout'`, and `'Date'`) will be mocked by default.
1994+
`'setTimeout'`, `'clearTimeout'`, `'setImmediate'`, `'clearImmediate'`, and
1995+
`'Date'`) will be mocked by default.
19951996
* `now` {number | Date} An optional number or Date object representing the
19961997
initial time (in milliseconds) to use as the value
19971998
for `Date.now()`. **Default:** `0`.
@@ -2046,10 +2047,11 @@ mock.timers.enable({ apis: ['Date'], now: new Date() });
20462047

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

2049-
All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, and `'clearTimeout'`)
2050-
will be mocked. The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout`
2051-
functions from `node:timers`, `node:timers/promises`,
2052-
and `globalThis` will be mocked. As well as the global `Date` object.
2050+
All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, `'clearTimeout'`,
2051+
`'setImmediate'`, and `'clearImmediate'`) will be mocked. The `setInterval`,
2052+
`clearInterval`, `setTimeout`, `clearTimeout`, `setImmediate`, and
2053+
`clearImmediate` functions from `node:timers`, `node:timers/promises`, and
2054+
`globalThis` will be mocked. As well as the global `Date` object.
20532055

20542056
### `timers.reset()`
20552057

@@ -2080,7 +2082,7 @@ mock.timers.reset();
20802082

20812083
Calls `timers.reset()`.
20822084

2083-
### `timers.tick(milliseconds)`
2085+
### `timers.tick([milliseconds])`
20842086

20852087
<!-- YAML
20862088
added:
@@ -2091,7 +2093,7 @@ added:
20912093
Advances time for all mocked timers.
20922094

20932095
* `milliseconds` {number} The amount of time, in milliseconds,
2094-
to advance the timers.
2096+
to advance the timers. **Default:** `1`.
20952097

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

0 commit comments

Comments
 (0)