From 139c26b67f93c56758d45bd814a56926ebf95778 Mon Sep 17 00:00:00 2001 From: Deokjin Kim Date: Thu, 16 May 2024 01:02:33 +0900 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/49534#discussion_r1597457356 PR-URL: https://github.com/nodejs/node/pull/52969 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Chemi Atlow Reviewed-By: Moshe Atlow --- doc/api/test.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/api/test.md b/doc/api/test.md index 7d9322362f56b3..f4abbb2177654d 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -1991,7 +1991,8 @@ Enables timer mocking for the specified timers. The currently supported timer values are `'setInterval'`, `'setTimeout'`, `'setImmediate'`, and `'Date'`. **Default:** `['setInterval', 'setTimeout', 'setImmediate', 'Date']`. If no array is provided, all time related APIs (`'setInterval'`, `'clearInterval'`, - `'setTimeout'`, `'clearTimeout'`, and `'Date'`) will be mocked by default. + `'setTimeout'`, `'clearTimeout'`, `'setImmediate'`, `'clearImmediate'`, and + `'Date'`) will be mocked by default. * `now` {number | Date} An optional number or Date object representing the initial time (in milliseconds) to use as the value for `Date.now()`. **Default:** `0`. @@ -2046,10 +2047,11 @@ mock.timers.enable({ apis: ['Date'], now: new Date() }); Alternatively, if you call `mock.timers.enable()` without any parameters: -All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, and `'clearTimeout'`) -will be mocked. The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout` -functions from `node:timers`, `node:timers/promises`, -and `globalThis` will be mocked. As well as the global `Date` object. +All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, `'clearTimeout'`, +`'setImmediate'`, and `'clearImmediate'`) will be mocked. The `setInterval`, +`clearInterval`, `setTimeout`, `clearTimeout`, `setImmediate`, and +`clearImmediate` functions from `node:timers`, `node:timers/promises`, and +`globalThis` will be mocked. As well as the global `Date` object. ### `timers.reset()` @@ -2080,7 +2082,7 @@ mock.timers.reset(); Calls `timers.reset()`. -### `timers.tick(milliseconds)` +### `timers.tick([milliseconds])`