Skip to content

test: run unit tests on warpdom instead of jsdom - #1700

Open
sonukapoor wants to merge 1 commit into
downshift-js:masterfrom
sonukapoor:test/warpdom-environment
Open

sonukapoor wants to merge 1 commit into
downshift-js:masterfrom
sonukapoor:test/warpdom-environment

Conversation

@sonukapoor

Copy link
Copy Markdown

Pull Request

What

Runs the Jest unit tests (test:cover) and the build tests (test:build) on warpdom instead of jsdom. warpdom is a DOM implementation for unit tests that I maintain; it is written from the WHATWG specifications with the goal that every test gets the same result as on jsdom, only faster. This is a proposal: happy to adjust it or close it if it is not wanted.

Why

The unit tests run about 1.6x faster, with every test keeping its result.

On a GitHub-hosted Ubuntu runner, 2 workers, one warm-up and 5 timed rounds alternating jsdom and warpdom, at master (2026-10-16):

jsdom warpdom
Unit tests 8.2 s 5.0 s
Speedup 1.64x (rounds 1.59-1.69x)
Tests with a different status 0

Locally (Apple M4 Pro, Node 22.23, --maxWorkers=2), on this branch and on its parent commit with jsdom, compared test by test with Jest's --json output:

jsdom warpdom
Unit tests (jest --coverage) 1,110 passed, 92 suites 1,110 passed, 92 suites
Build tests (other/misc-tests) 8 passed 8 passed
SSR test (Node, unchanged) 1 passed 1 passed
Tests with a different status 0
Unit tests, Jest's time 7.6 s 5.1 s

Coverage stays at 100%; the thresholds pass on both. One local run each, so the local times are indicative only.

How

testEnvironment: 'warpdom' replaces the jsdom environment that kcd-scripts/jest picks for React projects, and the jsdom in other/misc-tests/jest.config.js. jest-environment-warpdom lets Jest find warpdom by that name.

Changes

  • jest.config.js: testEnvironment: 'warpdom'.
  • other/misc-tests/jest.config.js: testEnvironment: 'warpdom' instead of 'jsdom'.
  • other/ssr/jest.config.js: the comment says the other tests run with a DOM (warpdom); the SSR test stays on Node.
  • package.json: warpdom (^0.1.3) and jest-environment-warpdom (^0.1.0) as dev dependencies. Both are MIT licensed; their only new dependencies are parse5 8 and @rgrove/parse-xml 5.

No test changes. downshift has no direct jsdom dependency to remove: jsdom 20 stays installed through kcd-scripts, which depends on jest-environment-jsdom 29; nothing loads it after this change.

To reproduce the comparison on master, after npm install:

npx warpdom compare --rounds 3 --workers 2

It runs the suite on jsdom and on warpdom, alternating, and writes .warpdom-compare/report.md with every test whose status changes and the speedup. It uses a temporary wrapper config and changes no files. Or check out this branch and run npm run test:cover and npm run build-and-test.

Caveats:

  • warpdom is pre-1.0 (0.1.3) and has far less mileage than jsdom. It is tested against 25 open-source test suites and the Web Platform Tests.
  • It differs from jsdom on purpose in a few places: Differences from jsdom. None of them changed a downshift test.
  • Like jsdom, it has no layout; the Playwright tests still cover scrolling and focus in a real browser.
  • warpdom declares Node.js 22.12 or later. The CI matrix includes Node 20, where npm prints an engine warning for it; the unit and build tests also pass on Node 20.20.2 locally. Happy to drop Node 20 from the matrix instead, if you prefer.

Checklist

  • Documentation N/A
  • Tests
  • TypeScript Types N/A
  • Ready to be merged (a proposal; happy to adjust)

Happy to close this if it's not wanted.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant