Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ops] Work around unit-tests in watch mode fails to set 'structuredCl…
Browse files Browse the repository at this point in the history
…one' (elastic#174444)

## Summary
@CoenWarmer found that `--watch` on jest tests will cause this sort of
error:
```
    TypeError: Cannot assign to read only property 'structuredClone' of object '[object global]'
```

There's some workaround suggested on this thread (although not
necessarily related): zloirock/core-js#1281

In the workaround, we set `structuredClone` to `{}`, this would allow
the currently offending 3rd party to overwrite it where it's currently
getting an error.
delanni committed Jan 11, 2024

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso
1 parent 71a99c1 commit 3b821e0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/kbn-test/jest-preset.js
Original file line number Diff line number Diff line change
@@ -124,4 +124,10 @@ module.exports = {
watchPathIgnorePatterns: ['.*/__tmp__/.*'],

resolver: '<rootDir>/packages/kbn-test/src/jest/resolver.js',

// Workaround to "TypeError: Cannot assign to read only property 'structuredClone' of object '[object global]'"
// This happens when we run jest tests with --watch after node20+
globals: {
structuredClone: {},
},
};

0 comments on commit 3b821e0

Please sign in to comment.