diff --git a/e2e/custom-jsdom-html/__tests__/test.js b/e2e/custom-jsdom-html/__tests__/test.js
index f5a0d65e9260..d67fc71c3335 100644
--- a/e2e/custom-jsdom-html/__tests__/test.js
+++ b/e2e/custom-jsdom-html/__tests__/test.js
@@ -1,3 +1,4 @@
-test('jsdom custom html', async () => {
+test('jsdom custom html', () => {
+ /* eslint-disable-next-line no-undef */
expect(document.getElementById('root')).toBeTruthy();
-});
\ No newline at end of file
+});
diff --git a/e2e/custom-jsdom-html/babel.config.js b/e2e/custom-jsdom-html/babel.config.js
index f6d9955fd649..1ac8f765542a 100644
--- a/e2e/custom-jsdom-html/babel.config.js
+++ b/e2e/custom-jsdom-html/babel.config.js
@@ -1,5 +1,12 @@
module.exports = {
- preset: [['@babel/env', {
- targets: 'current'
- }]]
-}
\ No newline at end of file
+ presets: [
+ [
+ '@babel/env',
+ {
+ targets: {
+ node: 'current',
+ },
+ },
+ ],
+ ],
+};
diff --git a/packages/jest-environment-jsdom/src/index.ts b/packages/jest-environment-jsdom/src/index.ts
index 6564d9e675fe..8db58a76a36e 100644
--- a/packages/jest-environment-jsdom/src/index.ts
+++ b/packages/jest-environment-jsdom/src/index.ts
@@ -31,19 +31,26 @@ class JSDOMEnvironment implements JestEnvironment {
moduleMocker: ModuleMocker | null;
constructor(config: Config.ProjectConfig, options?: EnvironmentContext) {
- this.dom = new JSDOM(typeof config.testEnvironmentOptions.html === 'string' ? config.testEnvironmentOptions.html : '', {
- pretendToBeVisual: true,
- resources:
- typeof config.testEnvironmentOptions.userAgent === 'string'
- ? new ResourceLoader({
- userAgent: config.testEnvironmentOptions.userAgent,
- })
- : undefined,
- runScripts: 'dangerously',
- url: config.testURL,
- virtualConsole: new VirtualConsole().sendTo(options?.console || console),
- ...config.testEnvironmentOptions,
- });
+ this.dom = new JSDOM(
+ typeof config.testEnvironmentOptions.html === 'string'
+ ? config.testEnvironmentOptions.html
+ : '',
+ {
+ pretendToBeVisual: true,
+ resources:
+ typeof config.testEnvironmentOptions.userAgent === 'string'
+ ? new ResourceLoader({
+ userAgent: config.testEnvironmentOptions.userAgent,
+ })
+ : undefined,
+ runScripts: 'dangerously',
+ url: config.testURL,
+ virtualConsole: new VirtualConsole().sendTo(
+ options?.console || console,
+ ),
+ ...config.testEnvironmentOptions,
+ },
+ );
const global = (this.global = this.dom.window.document
.defaultView as unknown as Win);