File tree 3 files changed +14
-7
lines changed
jest-config/src/__tests__
jest-environment-node/src
3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change 6
6
7
7
### Fixes
8
8
9
+ - ` [jest-environment-node] ` make ` globalThis.performance ` writable for Node 19 and fake timers ([ #13467 ] ( https://github.com/facebook/jest/pull/13467 ) )
10
+
9
11
### Chore & Maintenance
10
12
11
13
### Performance
Original file line number Diff line number Diff line change @@ -1082,6 +1082,10 @@ describe('preset', () => {
1082
1082
jest . requireActual ( './jest-preset.json' ) ,
1083
1083
) ;
1084
1084
1085
+ const errorMessage = semver . satisfies ( process . versions . node , '<19.0.0' )
1086
+ ? / U n e x p e c t e d t o k e n } i n J S O N a t p o s i t i o n ( 1 0 4 | 1 1 0 ) [ \s \S ] * a t /
1087
+ : 'SyntaxError: Expected double-quoted property name in JSON at position 104' ;
1088
+
1085
1089
await expect (
1086
1090
normalize (
1087
1091
{
@@ -1090,9 +1094,7 @@ describe('preset', () => {
1090
1094
} ,
1091
1095
{ } as Config . Argv ,
1092
1096
) ,
1093
- ) . rejects . toThrow (
1094
- / U n e x p e c t e d t o k e n } i n J S O N a t p o s i t i o n ( 1 0 4 | 1 1 0 ) [ \s \S ] * a t / ,
1095
- ) ;
1097
+ ) . rejects . toThrow ( errorMessage ) ;
1096
1098
} ) ;
1097
1099
1098
1100
test ( 'throws when preset evaluation throws type error' , async ( ) => {
@@ -1105,9 +1107,9 @@ describe('preset', () => {
1105
1107
{ virtual : true } ,
1106
1108
) ;
1107
1109
1108
- const errorMessage = semver . satisfies ( process . versions . node , '>= 16.9.1' )
1109
- ? " TypeError: Cannot read properties of undefined (reading 'call')"
1110
- : / T y p e E r r o r : C a n n o t r e a d p r o p e r t y ' c a l l ' o f u n d e f i n e d [ \s \S ] * a t / ;
1110
+ const errorMessage = semver . satisfies ( process . versions . node , '< 16.9.1' )
1111
+ ? / T y p e E r r o r : C a n n o t r e a d p r o p e r t y ' c a l l ' o f u n d e f i n e d [ \s \S ] * a t /
1112
+ : " TypeError: Cannot read properties of undefined (reading 'call')" ;
1111
1113
1112
1114
await expect (
1113
1115
normalize (
Original file line number Diff line number Diff line change @@ -90,7 +90,10 @@ export default class NodeEnvironment implements JestEnvironment<Timer> {
90
90
configurable : descriptor . configurable ,
91
91
enumerable : descriptor . enumerable ,
92
92
value : val ,
93
- writable : descriptor . writable ,
93
+ writable :
94
+ descriptor . writable === true ||
95
+ // Node 19 makes performance non-readable. This is probably not the correct solution.
96
+ nodeGlobalsKey === 'performance' ,
94
97
} ) ;
95
98
return val ;
96
99
} ,
You can’t perform that action at this time.
0 commit comments