fix(jest): nextcloud/files Node structuredClone

Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
This commit is contained in:
skjnldsv 2024-12-10 14:38:26 +01:00
parent da33159f1e
commit 709b05e77d
2 changed files with 15 additions and 1 deletions

View file

@ -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
}
}

View file

@ -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: [