-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timers mock panic with sub-test #55849
Comments
Even simpler reproduction: import { test, beforeEach } from 'node:test'
beforeEach((t) => t.mock.timers.enable());
test(() => test());
It's failing here: node/lib/internal/test_runner/mock/mock_timers.js Lines 396 to 413 in be5a500
|
With above example,
|
I don't think we should set it to IMO The appropriate response should be an error that the mock is already enabled, as is done if you try to enable it twice. |
A better way to look at this is: import { test } from 'node:test'
test((outer) => {
outer.mock.timers.enable()
test((inner) => inner.mock.timers.enable())
}); When Then, when node/lib/internal/test_runner/mock/mock_timers.js Lines 380 to 383 in be5a500
IMO there are two paths that can be taken here: I'm inclined for (A). |
Opened #55858 |
Fixes #55849 PR-URL: #55858 Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
Fixes nodejs#55849 PR-URL: nodejs#55858 Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
Fixes nodejs#55849 PR-URL: nodejs#55858 Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
Fixes #55849 PR-URL: #55858 Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
Fixes #55849 PR-URL: #55858 Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
Version
v22.10.0
Platform
No response
Subsystem
No response
What steps will reproduce the bug?
1. Create a test file
a.test.mjs
2. Run the following command to test
How often does it reproduce? Is there a required condition?
Every time
What is the expected behavior? Why is that the expected behavior?
There should be not panic
What do you see instead?
Additional information
No response
The text was updated successfully, but these errors were encountered: