You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cd$(mktemp -d)
npm init -y
npm i jest@28
echo"jest.useFakeTimers(); it('foo', () => {})"> jest.test.js
npx jest jest.test.js
which produces this error:
FAIL ./jest.test.js
● Test suite failed to run
TypeError: Cannot assign to read only property 'performance' of object '[object global]'
> 1 | jest.useFakeTimers(); it('foo', () => {})
| ^
2 |
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)
at Object.<anonymous> (jest.test.js:1:21)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.237 s, estimated 1 s
Ran all test suites matching /jest.test.js/i.
The text was updated successfully, but these errors were encountered:
merceyz
changed the title
global.performance is no longer writable in v18.19.0Object.getOwnPropertyDescriptor('global.performance').writable is no longer true in v18.19.0
Jan 31, 2024
merceyz
changed the title
Object.getOwnPropertyDescriptor('global.performance').writable is no longer true in v18.19.0Object.getOwnPropertyDescriptor(global, 'performance').writable is no longer true in v18.19.0
Jan 31, 2024
From a skim, yes, it looks like it used to be true, and the identified commit (6466acb) omitted the writable property from the options passed to ObjectDefineProperty, which disabled it. I'm not super familiar with Node development, but if the behavior of ObjectDefineProperty() mirrors Object.defineProperty(), then writable defaults to false; an omission of that key will disable writability.
Version
v18.19.0
Platform
Linux unknown 5.15.0-92-generic #102-Ubuntu SMP Wed Jan 10 09:33:48 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
bootstrap
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
global.performance
should remainwritable
between minor versions.What do you see instead?
Additional information
Ref #51048.
Ref jestjs/jest#14741.
git bisect
points to 6466acb.Tests started failing in https://github.com/yarnpkg/berry/tree/a8857df67ba769e265b49542af9c31d9f05ee681 which uses
jest@28
, minimal reproduction for that:which produces this error:
The text was updated successfully, but these errors were encountered: