From dd65ba0934971d1e7874a4f9d7921f23d107f6ee Mon Sep 17 00:00:00 2001 From: Sonu Kapoor Date: Fri, 16 Oct 2026 09:18:52 -0400 Subject: [PATCH] test: run unit tests on warpdom instead of jsdom Set testEnvironment to warpdom in the unit and build test configs and add warpdom and jest-environment-warpdom as dev dependencies. All 1,110 unit and 8 build tests keep their result, with 100% coverage. --- jest.config.js | 1 + other/misc-tests/jest.config.js | 2 +- other/ssr/jest.config.js | 4 ++-- package.json | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/jest.config.js b/jest.config.js index 24d713c43..d3f3b7115 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,6 +1,7 @@ const jestConfig = require('kcd-scripts/jest') module.exports = Object.assign(jestConfig, { + testEnvironment: 'warpdom', coveragePathIgnorePatterns: [ ...jestConfig.coveragePathIgnorePatterns, '.macro.js$', diff --git a/other/misc-tests/jest.config.js b/other/misc-tests/jest.config.js index 08f06d7da..7101df888 100644 --- a/other/misc-tests/jest.config.js +++ b/other/misc-tests/jest.config.js @@ -3,7 +3,7 @@ const babelHelpersList = require('@babel/helpers').list module.exports = Object.assign(jestConfig, { roots: ['.'], - testEnvironment: 'jsdom', + testEnvironment: 'warpdom', transform: { '^.+\\.(js|jsx|mjs)$': ['babel-jest', {rootMode: 'upward'}], }, diff --git a/other/ssr/jest.config.js b/other/ssr/jest.config.js index 17153eeb1..37e45c78f 100644 --- a/other/ssr/jest.config.js +++ b/other/ssr/jest.config.js @@ -1,6 +1,6 @@ // This is separate because the test environment is set via the config -// and we want most of our tests to run with jsdom, but we still want -// to make sure that the server rendering use case continues to work. +// and we want most of our tests to run with a DOM (warpdom), but we still +// want to make sure that the server rendering use case continues to work. const jestConfig = require('kcd-scripts/config').jest module.exports = Object.assign(jestConfig, { diff --git a/package.json b/package.json index 2183e45ee..ceaa7f8fa 100644 --- a/package.json +++ b/package.json @@ -126,6 +126,7 @@ "flow-bin": "^0.299.0", "flow-coverage-report": "^0.8.0", "get-pkg-repo": "5.0.0", + "jest-environment-warpdom": "^0.1.0", "kcd-scripts": "^17.0.0", "node-polyfill-webpack-plugin": "^4.1.0", "npm-run-all": "^4.1.5", @@ -139,7 +140,8 @@ "react-test-renderer": "^18.3.1", "serve": "^14.2.5", "start-server-and-test": "^2.1.3", - "typescript": "^5.9.3" + "typescript": "^5.9.3", + "warpdom": "^0.1.3" }, "overrides": { "eslint-plugin-react-hooks": "^7.1.1"