Skip to content

Commit

Permalink
[Ops] Work around unit-tests in watch mode fails to set 'structuredCl…
Browse files Browse the repository at this point in the history
…one' (#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.
  • Loading branch information
delanni committed Jan 8, 2024
1 parent d672936 commit a5dbf26
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
Expand Up @@ -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 a5dbf26

Please sign in to comment.