-
Notifications
You must be signed in to change notification settings - Fork 264
/
FixJSDOMEnvironment.ts
18 lines (16 loc) · 811 Bytes
/
FixJSDOMEnvironment.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import JSDOMEnvironment from "jest-environment-jsdom";
import { cloneDeep } from "lodash";
// 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);
// TODO Tests aren't polyfilled.
this.global.structuredClone = cloneDeep;
// 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)");
}
}