Skip to content

Commit fbf0fa8

Browse files
authored
fix(runtime): handle missing replaceProperty (#13823)
1 parent c78905c commit fbf0fa8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
### Fixes
99

1010
- `[@jest/expect-utils]` `toMatchObject` diffs should include `Symbol` properties ([#13810](https://github.com/facebook/jest/pull/13810))
11+
- `[jest-runtime]` Handle missing `replaceProperty` ([#13823](https://github.com/facebook/jest/pull/13823))
1112

1213
### Chore & Maintenance
1314

packages/jest-runtime/src/index.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -2319,9 +2319,14 @@ export default class Runtime {
23192319
'Your test environment does not support `mocked`, please update it.',
23202320
);
23212321
});
2322-
const replaceProperty = this._moduleMocker.replaceProperty.bind(
2323-
this._moduleMocker,
2324-
);
2322+
const replaceProperty =
2323+
typeof this._moduleMocker.replaceProperty === 'function'
2324+
? this._moduleMocker.replaceProperty.bind(this._moduleMocker)
2325+
: () => {
2326+
throw new Error(
2327+
'Your test environment does not support `jest.replaceProperty` - please ensure its Jest dependencies are updated to version 29.4 or later',
2328+
);
2329+
};
23252330

23262331
const setTimeout = (timeout: number) => {
23272332
this._environment.global[testTimeoutSymbol] = timeout;

0 commit comments

Comments
 (0)