GithubHelp home page GithubHelp logo

Comments (1)

SimenB avatar SimenB commented on April 27, 2024 1

That's because you're using jsdom@24 in your test, which is the newest version. If you install jsdom@20 (which is what ships with Jest) you can see the test failing in the same way with the builtin test runner.

jest-environment-jsdom@next (v30 alpha) ships with jsdom@22. You can setup a version with jsdom@24 using https://www.npmjs.com/package/@jest/environment-jsdom-abstract

diff --git c/custom-jsdom-env.js w/custom-jsdom-env.js
new file mode 100644
index 0000000..4b132f6
--- /dev/null
+++ w/custom-jsdom-env.js
@@ -0,0 +1,7 @@
+const { default: TestEnvironment } = require('@jest/environment-jsdom-abstract');
+
+module.exports = class JSDOMEnv extends TestEnvironment {
+  constructor(config, context) {
+    super(config, context, require('jsdom'));
+  }
+}
diff --git c/jest.config.js w/jest.config.js
index 69f6556..7d1219c 100644
--- c/jest.config.js
+++ w/jest.config.js
@@ -1,6 +1,6 @@
 module.exports = {
   // comment out this line and the test is successful
-  testEnvironment: 'jsdom',
+  testEnvironment: './custom-jsdom-env.js',
   collectCoverage: false,
   moduleFileExtensions: ['js'],
   resetMocks: true,
diff --git c/package.json w/package.json
index 2219366..fe9e848 100644
--- c/package.json
+++ w/package.json
@@ -10,8 +10,8 @@
   "author": "",
   "license": "ISC",
   "dependencies": {
+    "@jest/environment-jsdom-abstract": "^30.0.0-alpha.3",
     "jest": "^29.7.0",
-    "jest-environment-jsdom": "^29.7.0",
     "jsdom": "^24.0.0",
     "whatwg-url": "^14.0.0"
   },

from jest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.