-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Closed
Labels
test_runnerIssues and PRs related to the test runner subsystem.Issues and PRs related to the test runner subsystem.
Description
Version
main
Platform
Linux s7 5.15.0-69-generic #76-Ubuntu SMP Fri Mar 17 17:19:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
test
What steps will reproduce the bug?
Because of an incorrect early return here, when a mocked setInterval
is triggered, processing of timers stops, even if there are more timers queued, that are already due.
Pull request incoming.
`test.skip("setInterval stops processing of timers", async (t) => {
t.mock.timers.enable({ apis: ["setInterval", "setTimeout"] });
const f1 = t.mock.fn();
const f2 = t.mock.fn();
setInterval(f1, 1000);
setTimeout(f2, 1001);
assert.strictEqual(f1.mock.callCount(), 0);
assert.strictEqual(f2.mock.callCount(), 0);
t.mock.timers.tick(1001);
assert.strictEqual(f1.mock.callCount(), 1);
assert.strictEqual(f2.mock.callCount(), 1);
});
fails with:
❯ ~/src/libs/node/node index.mjs
✖ setInterval stops processing of timers (2.266168ms)
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
0 !== 1
at TestContext.<anonymous> (file:///home/mfischer/src/tests/node-mock-timers/index.mjs:89:10)
at Test.runInAsyncScope (node:async_hooks:206:9)
at Test.run (node:internal/test_runner/test:631:25)
at Test.processPendingSubtests (node:internal/test_runner/test:374:18)
at Test.postRun (node:internal/test_runner/test:715:19)
at Test.run (node:internal/test_runner/test:673:12)
at async Test.processPendingSubtests (node:internal/test_runner/test:374:7) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: 0,
expected: 1,
operator: 'strictEqual'
}
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
All timers that are due should be processed
What do you see instead?
Timers that are due are not triggered
Additional information
No response
Metadata
Metadata
Assignees
Labels
test_runnerIssues and PRs related to the test runner subsystem.Issues and PRs related to the test runner subsystem.