Skip to content

[code-infra] Replace jsdom with warpdom in the unit tests - #49503

Draft
sonukapoor wants to merge 1 commit into
mui:masterfrom
sonukapoor:test/warpdom-environment
Draft

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

Conversation

@sonukapoor

Copy link
Copy Markdown

Proof of concept for #49502; the discussion is there. Opened as a draft.

This replaces jsdom with warpdom, a DOM implementation for tests that aims at jsdom's results, only faster, in the Vitest projects that use jsdom:

  • package.json, pnpm-lock.yaml: add warpdom (0.1.3) and vitest-environment-warpdom (0.1.0) as dev dependencies and remove the direct jsdom dev dependency, which nothing else imports;
  • vitest.shared.mts: environment: jsdom ? 'warpdom' : 'node'. I kept the jsdom option name to keep the diff to one line; happy to rename it.

Nothing else changes: no test edits, and Node and browser projects are unchanged. jsdom stays in pnpm-lock.yaml only as Vitest's optional peer, which pnpm resolves; nothing loads it. No @vitest-environment jsdom comments in test files needed switching (the one in rating.md is a docs example).

Results

pnpm test:node run with this change and without it, on master f3fb528 (2026-10-14; local, Apple M4 Pro, Node 22.23.3; one run each on a busy machine, so the times are indicative only):

jsdom warpdom
Test files 464 passed, 7 skipped 464 passed, 7 skipped
Tests 6,917 passed, 895 skipped 6,917 passed, 895 skipped
Tests with a different status 0
Duration (Vitest) 39.9 s 22.4 s (1.79x)

Rebased on today's master (f24a0df), the branch gives 6,918 passed and 895 skipped (master added one test).

On a GitHub-hosted Ubuntu runner with 2 workers (5 rounds, mui-material, mui-system, mui-utils, mui-lab), the same switch took 267.3 s down to 144.3 s (1.85x, 95% CI 1.83-1.87x), with 0 tests changing in every round; details in #49502.

How to reproduce

On master, after pnpm install:

TZ=UTC TEST_SCOPE=node npx warpdom compare --rounds 3

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 changes no files. Or check out this branch and run pnpm test:node run.

Caveats

Happy to close this if it's not wanted.

Switch the Vitest environment of the projects that use jsdom to warpdom, a
DOM implementation for tests that aims at jsdom's results, and remove the
direct jsdom dev dependency, which nothing else imports. Node and browser
projects are unchanged.
@code-infra-dashboard

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-49503--material-ui.netlify.app/
QR code for https://deploy-preview-49503--material-ui.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

This branch has not been deployed

No deployments
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