TEST: Add a NS2 test (finally) (#458)

This commit is contained in:
David Walker
2023-04-01 04:45:23 -07:00
committed by GitHub
parent c730d6ed82
commit 8c4b992d59
4 changed files with 78 additions and 20 deletions

15
FixJSDOMEnvironment.ts Normal file
View File

@@ -0,0 +1,15 @@
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);
// 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)");
}
}