The new feature allows developers to write more reliable and predictable tests for time-dependent functionality.
It includes MockTimers
with the ability to mock setTimeout
, setInterval
from globals
, node:timers
, and node:timers/promises
.
The feature provides a simple API to advance time, enable specific timers, and release all timers.
import assert from 'node:assert';
import { test } from 'node:test';
test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => {
const fn = context.mock.fn();
// Optionally choose what to mock
context.mock.timers.enable(['setTimeout']);
const nineSecs = 9000;
setTimeout(fn, nineSecs);
const threeSeconds = 3000;
context.mock.timers.tick(threeSeconds);
context.mock.timers.tick(threeSeconds);
context.mock.timers.tick(threeSeconds);
assert.strictEqual(fn.mock.callCount(), 1);
});
This feature was contributed by Erick Wendel in #47775.
Node is adding support to the explicit resource management
proposal to its resources allowing users of TypeScript/babel to use using
/await using
with
V8 support for everyone else on the way.
This feature was contributed by Moshe Atlow and Benjamin Gruenbaum in #48518.
fe333d2584
] - crypto: update root certificates to NSS 3.90 (Node.js GitHub Bot) #4841660c2ea4e79
] - doc: add vmoroz to collaborators (Vladimir Morozov) #485275cacdf9e6b
] - doc: add kvakil to collaborators (Keyhan Vakil) #48449504d1d7bdc
] - (SEMVER-MINOR) tls: add ALPNCallback server option for dynamic ALPN negotiation (Tim Perry) #45190Updates may require up to 24 hours to propagate to mirrors. If the following command doesn't work, please retry later:
sudo dnf upgrade --refresh --advisory=FEDORA-2023-b285cd8ba8
Please login to add feedback.
This update's test gating status has been changed to 'waiting'.
This update has been submitted for testing by bodhi.
This update's test gating status has been changed to 'failed'.
This update has been pushed to testing.
This update's test gating status has been changed to 'passed'.
no regressions noted
works fine
This update has been submitted for stable by bodhi.
This update has been pushed to stable.