NodeJS 24 shipped last week and one of the changes was a standard API for mocking out timers and manually advancing them. This allows among other things to test very narrow race conditions by single stepping the timers and checking state in between them, without having to resort to very long timers that slow the tests down.
Also timers/promises was added in Node 16, and could be used to replace the delay module in the tests.
const res = await setTimeout(100, 'result');
NodeJS 24 shipped last week and one of the changes was a standard API for mocking out timers and manually advancing them. This allows among other things to test very narrow race conditions by single stepping the timers and checking state in between them, without having to resort to very long timers that slow the tests down.
Also timers/promises was added in Node 16, and could be used to replace the delay module in the tests.