From 709b05e77ddbd213419a0a6428d618d18f7b8523 Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Tue, 10 Dec 2024 14:38:26 +0100 Subject: [PATCH] fix(jest): nextcloud/files Node structuredClone Signed-off-by: skjnldsv --- __tests__/FixJSDOMEnvironment.ts | 14 ++++++++++++++ jest.config.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 __tests__/FixJSDOMEnvironment.ts diff --git a/__tests__/FixJSDOMEnvironment.ts b/__tests__/FixJSDOMEnvironment.ts new file mode 100644 index 0000000000000..974a06da85821 --- /dev/null +++ b/__tests__/FixJSDOMEnvironment.ts @@ -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) { + 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 + } + +} diff --git a/jest.config.ts b/jest.config.ts index 91f4f279afa17..9299c70648a60 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -57,7 +57,7 @@ const config: Config = { clearMocks: true, setupFilesAfterEnv: ['/__tests__/jest-setup.ts'], - testEnvironment: 'jest-environment-jsdom', + testEnvironment: './__tests__/FixJSDOMEnvironment.ts', preset: 'ts-jest/presets/js-with-ts', roots: [