Skip to content

Run the unit tests in Chromium instead of jsdom - #3

Open
lxsmnsyc wants to merge 1 commit into
solidjs-community:mainfrom
lxsmnsyc:test/vitest-browser-mode
Open

Run the unit tests in Chromium instead of jsdom#3
lxsmnsyc wants to merge 1 commit into
solidjs-community:mainfrom
lxsmnsyc:test/vitest-browser-mode

Conversation

@lxsmnsyc

@lxsmnsyc lxsmnsyc commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Vitest browser mode replaces the jsdom environment for the client project. All 118 existing tests pass unchanged, in about the same time, at the same coverage.

  • Delete test/setup.ts. It only existed to stub IntersectionObserver, which jsdom does not implement.
  • Drop the jsdom dependency and add @vitest/browser-playwright.
  • Add unit tests for inView. They need a real IntersectionObserver, so the prop had no client-side test before.
  • Raise the coverage thresholds to match the new numbers.

jsdom also implements no Web Animations API, so animated values were never really interpolated and several tests worked around its quirks. Those comments are corrected. A browser resolves an unset opacity to 1 rather than 0, reading computed style off a detached node no longer throws, and real layout exists, so the layout stub is now for determinism rather than necessity. Building a PointerEvent by hand still defaults to isPrimary: false, so that workaround stays.

Only Chromium runs here. The Playwright suite already covers Firefox and WebKit at the app level, which is where engine differences matter. Running the unit tests across all three surfaces two WebKit failures, in drag pointer capture and in focus-visible, that are better chased there.

CI installs Chromium before the test job. The Node 22 pin stays, but its reason is now Vite 8 rather than the undici problem that came with jsdom.

135 tests pass. Lint, types, build, e2e and Prettier are clean.

Vitest browser mode replaces the jsdom environment for the client project.
All 118 existing tests pass unchanged, in about the same time, at the same
coverage.

- Delete `test/setup.ts`. It only existed to stub `IntersectionObserver`,
  which jsdom does not implement.
- Drop the `jsdom` dependency and add `@vitest/browser-playwright`.
- Add unit tests for `inView`. They need a real `IntersectionObserver`, so
  the prop had no client-side test before.
- Raise the coverage thresholds to match the new numbers.

jsdom also implements no Web Animations API, so animated values were never
really interpolated and several tests worked around its quirks. Those
comments are corrected. A browser resolves an unset `opacity` to `1` rather
than `0`, reading computed style off a detached node no longer throws, and
real layout exists, so the layout stub is now for determinism rather than
necessity. Building a `PointerEvent` by hand still defaults to
`isPrimary: false`, so that workaround stays.

Only Chromium runs here. The Playwright suite already covers Firefox and
WebKit at the app level, which is where engine differences matter. Running
the unit tests across all three surfaces two WebKit failures, in drag
pointer capture and in focus-visible, that are better chased there.

CI installs Chromium before the test job. The Node 22 pin stays, but its
reason is now Vite 8 rather than the undici problem that came with jsdom.

135 tests pass. Lint, types, build, e2e and Prettier are clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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