Closed
Description
Tooling Report Checklist
- I have pulled the latest
main
branch of the repository. - I have searched for related issues and found none that matched my request.
- This is the appropriate issue form for the tooling issue I would like to report.
Expected
I expected the tests to run and fail when I ran npm run test -- 1
.
Actual
I received this error:
FAIL 01-syntactic-sugar/index.test.js
● Test suite failed to run
TypeError: Cannot assign to read only property 'performance' of object '[object global]'
at hijackMethod (../../../node_modules/@sinonjs/fake-timers/src/fake-timers-src.js:946:32)
at Object.install (../../../node_modules/@sinonjs/fake-timers/src/fake-timers-src.js:1733:17)
at FakeTimers.useFakeTimers (../../../node_modules/@jest/fake-timers/build/modernFakeTimers.js:110:36)
So I went into jest.config.js
.
The original file is:
module.exports = {
fakeTimers: { enableGlobally: true },
transform: {
"^.+\\.(t|j)sx?$": [
"@swc/jest",
{
jsc: {
target: "es2021",
},
},
],
},
};
I changed it to:
module.exports = {
fakeTimers: { enableGlobally: false },
transform: {
"^.+\\.(t|j)sx?$": [
"@swc/jest",
{
jsc: {
target: "es2021",
},
},
],
},
};
After changing enableGlobally from true to false, my tests failed the way I expected them to. I then fixed the obvious issues in my code and the tests passed.
Additional Info
I'm not really sure how to document this finding. Again, it should only affect users with node v19. I didn't try this out, but it was recommended in a post.
My node version is v19.9.0.