Skip to content

Test: Run rendered browser behavior in Vitest Browser Mode - #80995

Merged
ciampo merged 33 commits into
trunkfrom
codex/vitest-consolidated-05-browser-mode
Sep 10, 2026
Merged

ciampo merged 33 commits into
trunkfrom
codex/vitest-consolidated-05-browser-mode

Conversation

@ciampo

@ciampo ciampo commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Part of #80855.

What?

Move rendered CSS, browser API, focus, and native interaction coverage from jsdom to 89 colocated Vitest Browser Mode suites.

Why?

jsdom remains useful for DOM semantics and component logic, but it cannot prove browser rendering, layout, focusability, viewport behavior, scrolling, or native input.

How?

Run the migrated suites in a separate Chromium CI job, load the production CSS each assertion needs, and keep non-rendered behavior in jsdom. Remove the synthetic visibility and geometry setup that these browser tests replace.

Migration details
  • The complete Browser project now runs 90 files and 1,277 tests.
  • Focus navigation, caret geometry, observers, media queries, transitions, scrolling, and native keyboard and pointer behavior run in Browser Mode.
  • Broad style snapshots become computed-style or browser-behavior assertions while focused semantic and public class contracts remain.
  • Browser React tests use vitest-browser-react; convention checks prevent the Testing Library React renderer from returning.
  • Browser artifacts resolve from the repository root, CI uses one unsharded Node 24 Browser job, and failure screenshots remain enabled without trace archives.
  • The shared visibility helper, the Jest-wide getClientRects polyfill, and the remaining @ariakit/test dependencies are removed.
Historical local benchmarks

Three consecutive warm full-suite runs on the same machine showed the following medians. The suite grew between measurements, so this is not an identical-test-set benchmark.

Version Files Tests Vitest duration Wall time
Vitest 4 73 1,167 30.30s 33.43s
Vitest 5 76 1,180 22.95s 25.92s
Change +3 +13 -24.3% -22.5%

For 244 exact-name-matched tests across 26 corresponding files, the warm Browser Mode wall-time median was 6.46s compared with 5.06s in jsdom. Both used Vitest 5.0.0 and Node 24.20.0.

Testing Instructions

  1. Run npm run test:unit:routing.
  2. Run npm run test:unit:conventions.
  3. Run npm run test:unit:vitest -- --project=browser.
  4. Run npm run test:unit:vitest:shuffled -- --project=browser.
Keyboard coverage

No production UI is added. Browser tests exercise Tab, arrow keys, Enter, Escape, focus movement, caret positioning, and pointer input across the migrated interfaces.

Use of AI Tools

Codex assisted with implementation and verification. The author reviewed the changes and Browser output.

@github-actions github-actions Bot added [Package] Components /packages/components [Package] Block editor /packages/block-editor labels Jul 30, 2026
@github-actions

github-actions Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Size Change: +26 B (0%)

Total Size: 7.71 MB

📦 View Changed
Filename Size Change
build/scripts/dom/index.min.js 5.13 kB +26 B (+0.51%)

compressed-size-action

@ciampo
ciampo force-pushed the codex/vitest-consolidated-04-test-migration branch from 58ecf75 to 59f56a3 Compare July 30, 2026 23:47
@ciampo
ciampo force-pushed the codex/vitest-consolidated-05-browser-mode branch from d779272 to 86413d3 Compare July 30, 2026 23:48
@github-actions

github-actions Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

Flaky tests detected in 827cc90.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/31577736315
📝 Reported tests:

As a user I want to be able to create a navigation overlay for a specific navigation block in /test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('region', { name: /(Editor publish|Save panel)/ }).getByRole('button', { name: 'Save', exact: true })

    at Editor.saveSiteEditorEntities (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/site-editor.ts:42:5)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:90:4
As a user I want to be able to customize the navigation overlay with styled content in /test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js, passed after 2 failed attempts.
Error: apiRequestContext.fetch: socket hang up
Call log:
  - → GET http://localhost:8889/wp-json/wp/v2/templates
    - user-agent: Playwright/1.62.1 (x64; ubuntu 24.04) node/20.20 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br
    - X-WP-Nonce: 76c10818ab
    - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_23778236db82f19306f247e20a353a99=admin%7C1786695817%7CvvszvnBvaI77byFokHF6vfK0yWntOMd9r8rH9pNDIxn%7C9c9d557d103999bd22a4d1a928391ef288af06421b67d6dc77c7cf6a96a3a1a9; wp-settings-time-1=1786524029

    at RequestUtils.rest (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/rest.ts:112:39)
    at RequestUtils.deleteAllTemplates (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/templates.ts:35:31)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:57:22
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('button', { name: 'Create overlay', exact: true })

    at createNavigationOverlay (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:44:28)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:113:4

@ciampo
ciampo force-pushed the codex/vitest-consolidated-04-test-migration branch from 59f56a3 to 8a81022 Compare July 31, 2026 00:38
@ciampo
ciampo force-pushed the codex/vitest-consolidated-05-browser-mode branch from 86413d3 to 1551ea0 Compare July 31, 2026 00:38
@ciampo
ciampo force-pushed the codex/vitest-consolidated-04-test-migration branch from 8a81022 to 6093aa4 Compare July 31, 2026 01:12
@ciampo
ciampo force-pushed the codex/vitest-consolidated-05-browser-mode branch 2 times, most recently from 9529651 to d5e3139 Compare July 31, 2026 01:20
@github-actions github-actions Bot added the [Package] Editor /packages/editor label Jul 31, 2026
@github-actions github-actions Bot added the [Package] Core data /packages/core-data label Jul 31, 2026
@ciampo
ciampo force-pushed the codex/vitest-consolidated-05-browser-mode branch from 4e3dd77 to 3eec742 Compare July 31, 2026 02:57
@ciampo
ciampo force-pushed the codex/vitest-consolidated-04-test-migration branch 2 times, most recently from 212550f to d0b6013 Compare July 31, 2026 19:21
@ciampo
ciampo force-pushed the codex/vitest-consolidated-05-browser-mode branch from 3eec742 to 8f70fba Compare July 31, 2026 19:21
@ciampo
ciampo force-pushed the codex/vitest-consolidated-04-test-migration branch from d0b6013 to ff71976 Compare July 31, 2026 19:36
@ciampo
ciampo force-pushed the codex/vitest-consolidated-05-browser-mode branch from 8f70fba to 7ce22c8 Compare July 31, 2026 19:36
@ciampo
ciampo force-pushed the codex/vitest-consolidated-04-test-migration branch from ff71976 to 34a139f Compare July 31, 2026 19:46
@ciampo
ciampo force-pushed the codex/vitest-consolidated-05-browser-mode branch from 7ce22c8 to 3b5ef70 Compare July 31, 2026 19:46
@ciampo
ciampo force-pushed the codex/vitest-consolidated-04-test-migration branch from 34a139f to ace2c35 Compare July 31, 2026 20:01
@ciampo
ciampo force-pushed the codex/vitest-consolidated-05-browser-mode branch from 3b5ef70 to 474050f Compare July 31, 2026 20:01
@ciampo
ciampo force-pushed the codex/vitest-consolidated-04-test-migration branch from ace2c35 to 9fb4115 Compare August 11, 2026 23:31
@ciampo
ciampo force-pushed the codex/vitest-consolidated-05-browser-mode branch from 474050f to ee36f98 Compare August 11, 2026 23:31
@github-actions github-actions Bot added [Package] Blob /packages/blob and removed [Package] Core data /packages/core-data labels Aug 11, 2026
@ciampo

ciampo commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

The Node 26 failure exposed a test-isolation bug: this test could start a real apiFetch request after jsdom teardown. I fixed it by mocking @wordpress/api-fetch; the exact Node 26 shard now passes.

I will merge once CI checks are green

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Blob /packages/blob [Package] Block editor /packages/block-editor [Package] Block library /packages/block-library [Package] Components /packages/components [Package] Compose /packages/compose [Package] Core data /packages/core-data [Package] DataViews /packages/dataviews [Package] DOM /packages/dom [Package] Editor /packages/editor [Package] Grid /packages/grid [Package] Icons /packages/icons [Package] Theme /packages/theme [Package] UI /packages/ui [Package] Widget Dashboard /packages/widget-dashboard Require PR update Forces open PRs to update from trunk [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants