Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime): handle missing replaceProperty #13823

Merged
merged 2 commits into from Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@
### Fixes

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

### Chore & Maintenance

Expand Down
11 changes: 8 additions & 3 deletions packages/jest-runtime/src/index.ts
Expand Up @@ -2319,9 +2319,14 @@ export default class Runtime {
'Your test environment does not support `mocked`, please update it.',
);
});
const replaceProperty = this._moduleMocker.replaceProperty.bind(
this._moduleMocker,
);
const replaceProperty =
typeof this._moduleMocker.replaceProperty === 'function'
? this._moduleMocker.replaceProperty.bind(this._moduleMocker)
: () => {
throw new Error(
'Your test environment does not support `jest.replaceProperty` - please ensure its Jest dependencies are updated to version 29.4 or later',
);
};

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