Node.js 20.4 puts a practical testing tool at the center of its July 4, 2023 release. Its new mock-timer support lets tests control selected timer APIs and advance virtual time, so a test can exercise a nine-second timeout in three three-second steps without waiting nine seconds in real time. The release announcement describes mocks for setTimeout and setInterval across globals, node:timers and node:timers/promises, along with controls to enable timers, advance time and release them. That makes the feature more than a faster clock: it gives tests explicit control over which timer behavior they replace. [story-s1][story-s2]

The release also added support for the explicit resource-management proposal in Node’s resources, enabling TypeScript and Babel users to apply using and await using patterns; the announcement said V8 support for other users was still forthcoming. Node 20.4 additionally introduced a TLS ALPNCallback option for dynamic application-protocol negotiation and updated root certificates to NSS 3.90. [story-s1]

For teams testing time-sensitive code, the notable shift is incremental: tests can make timer progression deterministic within the test, while applications still run against real timers unless their tests opt into the mock. The release note presents the mock-timer feature as an aid to reliability and predictability, not as a change to production timing. Its stated API scope matters: the announcement names specific timer entry points rather than claiming that every source of time in a process is controlled. [story-s1]

Source documents

  1. Node.js — Node.js 20.4.0 (Current)https://nodejs.org/en/blog/release/v20.4.0
  2. Node.js distribution index (JSON)https://nodejs.org/download/release/index.json