Run the unit tests in Chromium instead of jsdom - #3
Open
lxsmnsyc wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
test/setup.ts. It only existed to stubIntersectionObserver, which jsdom does not implement.jsdomdependency and add@vitest/browser-playwright.inView. They need a realIntersectionObserver, so the prop had no client-side test before.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
opacityto1rather than0, 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 aPointerEventby hand still defaults toisPrimary: 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.