2023-04-01 13:45:23 +02:00
|
|
|
import JSDOMEnvironment from "jest-environment-jsdom";
|
2024-02-10 10:10:19 +01:00
|
|
|
import { cloneDeep } from "lodash";
|
2023-04-01 13:45:23 +02:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
2024-02-10 10:10:19 +01:00
|
|
|
// TODO Tests aren't polyfilled.
|
|
|
|
this.global.structuredClone = cloneDeep;
|
2023-04-01 13:45:23 +02:00
|
|
|
// FIXME https://github.com/nodejs/node/issues/35889
|
|
|
|
// Add missing importActual() function to mirror requireActual(),
|
|
|
|
// which lets us work around the ESM bug.
|
|
|
|
// Wrap the construction of the function in eval, so that transpilers
|
|
|
|
// don't touch the import() call.
|
|
|
|
this.global.importActual = eval("url => import(url)");
|
|
|
|
}
|
|
|
|
}
|