Skip to content

[code-infra] Trim the shared browser test setup graph - #23426

Merged
LukasTy merged 3 commits into
mui:masterfrom
LukasTy:code-infra/trim-shared-test-setup-graph
Aug 26, 2026
Merged

LukasTy merged 3 commits into
mui:masterfrom
LukasTy:code-infra/trim-shared-test-setup-graph

Conversation

@LukasTy

@LukasTy LukasTy commented Aug 25, 2026

Copy link
Copy Markdown
Member

Follow-up in the same direction as #23424, but independent of it: the two PRs touch different lines of test/setupVitest.ts and do not conflict.

With isolate: false a page is never reloaded, and Vitest keeps every project's pages open until the whole run ends (vitest#10990), so whatever the shared setup imports is evaluated and held by every browser project for the entire run.

Changes

  1. test/setupVitest.ts no longer imports from the @mui/internal-test-utils package root. The root re-exports createRenderer, which statically imports react-dom/server, plus describeConformance - pulled into every page, including the projects that never render anything. configure has no subpath export, but setupVitest forwards its extra options straight to configure, so those options move into the setupVitest call and only @mui/internal-test-utils/env is imported.

  2. LicenseInfo now comes from @mui/x-license/utils/licenseInfo rather than the package root, which additionally evaluates the provider and telemetry graph.

  3. Removed packages/x-telemetry/vitest.config.browser.mts. Every test in that project is gated behind runIf(isJSDOM) and the browser config excludes the postinstall tests, so the project opened two browser pages that ran no tests at all. Coverage is unchanged in jsdom.

Measured

x-internal-gestures page, post-GC JS heap (CDP HeapProfiler.collectGarbage then Performance.getMetrics):

heap
master 28.85 MB
this PR 26.61 MB (-7.8%)

Plus two fewer pages from dropping the x-telemetry browser project.

This buys headroom; it does not fix the OOM. The floor is structural: a renderer costs roughly 275 MB of physical footprint of which only about 50 MB is JS heap, and Vitest holds 2 renderers per browser project alive for the whole run (vitest#10990, fix in vitest#10991).

Testing

  • Full browser suite: 758 passed, 4 skipped (762 files), 12861 tests, 0 page crashes.
  • jsdom for x-telemetry, x-license, x-date-pickers: 130 passed, 4 skipped.

Considered and left out

  • Moving sinon.restore() into a per-project setup. Sinon is about 341 KB per page and 7 browser projects never import it, but 15 of 21 do. Registering a majority-case cleanup per project is the wrong shape, and it silently drops the restore the first time a package adds a sinon usage. Worth doing only alongside a lint rule that enforces the pairing.
  • import config from 'react-transition-group/config'. Tried it; that entry is a legacy directory import that resolves to CJS, so the default export is undefined and the whole suite fails with Cannot read properties of undefined (reading 'config').
  • Importing configure from @testing-library/react/pure.js. That is a different function from @mui/internal-test-utils's configure, which sets MUI's own computedStyleSupportsPseudoElements flag. Swapping them would silently drop that behavior.
  • maxWorkers: 1. Measured: it does not reduce the page count. The run holds 2 renderers per project at both 1 and 2 workers (42 either way), and wall time was unchanged (134.0s vs 135.3s).
  • Dropping the x-license and x-charts-vendor browser projects. Unlike x-telemetry, both actually run tests in the browser (3 and 2 files), so removing them is a coverage decision rather than a no-op.

LukasTy and others added 2 commits August 25, 2026 18:52
`test/setupVitest.ts` imported from the `@mui/internal-test-utils` package
root, which re-exports `createRenderer` (and with it `react-dom/server`) plus
`describeConformance`. With `isolate: false` a page is never reloaded, so that
graph was evaluated in every browser page, including the projects that never
render anything.

`configure` has no subpath export, but `setupVitest` forwards its extra options
to `configure`, so the options move into the `setupVitest` call.

Also takes `LicenseInfo` from `@mui/x-license/utils/licenseInfo` instead of the
package root, which additionally evaluates the provider and telemetry graph.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Every test in the project is gated behind `runIf(isJSDOM)` and the browser
config excludes the postinstall tests, so the project opened two browser pages
that ran no tests. The coverage is unchanged in jsdom.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@code-infra-dashboard

code-infra-dashboard Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Deploy preview

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

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)
@mui/x-scheduler 0B(0.00%) 0B(0.00%)
@mui/x-scheduler-premium 0B(0.00%) 0B(0.00%)
@mui/x-chat 0B(0.00%) 0B(0.00%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes


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

@LukasTy LukasTy added test type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. labels Aug 26, 2026
@LukasTy
LukasTy requested a balanced review from Copilot August 26, 2026 06:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@LukasTy
LukasTy requested review from JCQuintas and Janpot August 26, 2026 06:01
@LukasTy
LukasTy merged commit d31fc88 into mui:master Aug 26, 2026
22 checks passed
@LukasTy
LukasTy deleted the code-infra/trim-shared-test-setup-graph branch August 26, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants