Closed
Description
Version
v22.10.0
Platform
No response
Subsystem
No response
What steps will reproduce the bug?
1. Create a test file a.test.mjs
import test from 'node:test'
test.beforeEach((t) => {
t.mock.timers.enable({ apis: ['Date'] })
t.mock.timers.tick(1731488301220) // 2024-11-13 16:58:21.220
})
test('test 1', async (t) => {
await t.test('sub test 1', async (t) => {
//
})
})
2. Run the following command to test
node --test --experimental-default-type=module ./a.test.mjs
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?
▶ test 1
✖ sub test 1 (1.0925ms)
TypeError [Error]: Cannot redefine property: Symbol(MockTimers)
at defineProperties (<anonymous>)
at #createDate (node:internal/test_runner/mock/mock_timers:381:5)
at Object.Date (node:internal/test_runner/mock/mock_timers:614:45)
at node:internal/test_runner/mock/mock_timers:635:74
at Array.forEach (<anonymous>)
at #toggleEnableTimers (node:internal/test_runner/mock/mock_timers:635:5)
at MockTimers.enable (node:internal/test_runner/mock/mock_timers:720:29)
at TestContext.<anonymous> (file:///path/to/a.test.mjs:4:19)
at TestHook.runInAsyncScope (node:async_hooks:211:14)
at TestHook.run (node:internal/test_runner/test:934:25)
Additional information
No response