Skip to content

Commit

Permalink
fix(jest): nextcloud/files Node structuredClone
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <[email protected]>
  • Loading branch information
skjnldsv committed Dec 10, 2024
1 parent da33159 commit 709b05e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions __tests__/FixJSDOMEnvironment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import JSDOMEnvironment from 'jest-environment-jsdom'

// https://github.com/facebook/jest/blob/v29.4.3/website/versioned_docs/version-29.4/Configuration.md#testenvironment-string
export default class FixJSDOMEnvironment extends JSDOMEnvironment {

constructor(...args: ConstructorParameters<typeof JSDOMEnvironment>) {
super(...args)

// https://github.com/jsdom/jsdom/issues/3363
// 31 ad above switched to vitest and don't have that issue
this.global.structuredClone = structuredClone
}

}
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const config: Config = {
clearMocks: true,
setupFilesAfterEnv: ['<rootDir>/__tests__/jest-setup.ts'],

testEnvironment: 'jest-environment-jsdom',
testEnvironment: './__tests__/FixJSDOMEnvironment.ts',
preset: 'ts-jest/presets/js-with-ts',

roots: [
Expand Down

0 comments on commit 709b05e

Please sign in to comment.