Run test suite in real Chromium via vitest browser mode - #6
Merged
Conversation
happy-dom restricts querySelector combinator matching to the query root's subtree, which is non-spec: real browsers match document-wide and only filter results to descendants. That divergence sits exactly on this library's core domain — selector resolution — so bugs in scoping behaviour can be invisible to an emulated-DOM suite. Switch the runner to vitest browser mode with the Playwright provider, executing all tests headless in Chromium: - migrate imports bun:test -> vitest (spyOn -> vi.spyOn); drop happy-dom, test/setup.ts, and bunfig.toml preload - add an environment guard test asserting spec-correct document-wide combinator matching, so a regression to an emulated DOM is caught - declare playwright explicitly in devDependencies (non-optional peer of @vitest/browser-playwright) so bunx playwright matches the provider's expectations - CI installs the Playwright chromium binary before running - record the bun-test exception in CLAUDE.md Suite: 33 pass in ~1.2s.
There was a problem hiding this comment.
Pull request overview
This PR migrates the project’s test execution from Bun’s in-process runner + happy-dom to Vitest browser mode backed by Playwright, so selector semantics are exercised in real headless Chromium (closing the spec gap that hid selector scoping issues).
Changes:
- Add Vitest browser-mode configuration using the Playwright provider (Chromium headless).
- Migrate tests from
bun:testtovitest(spyOn→vi.spyOn) and remove happy-dom registration/preload. - Update CI to install the Playwright Chromium browser and run
vitest runviabun run test.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
vitest.config.ts |
Adds Vitest browser-mode config using Playwright/Chromium headless. |
test/setup.ts |
Removes happy-dom global registrator setup (no longer needed). |
test/query.test.ts |
Switches test imports/mocking from bun:test to vitest (vi). |
test/integration.test.ts |
Switches test imports/mocking from bun:test to vitest (vi). |
test/helpers.test.ts |
Switches test imports from bun:test to vitest. |
test/harness.test.ts |
Replaces happy-dom registration check with DOM availability + adds spec-guard test for combinator matching. |
test/blessing.test.ts |
Switches test imports/mocking from bun:test to vitest (vi). |
test/barrel.test.ts |
Switches test imports from bun:test to vitest. |
package.json |
Updates test script to vitest run and adds Vitest/Playwright dev dependencies. |
CLAUDE.md |
Documents the testing exception: Vitest browser mode in real Chromium (vs bun test). |
bunfig.toml |
Removes Bun test preload configuration (no longer applicable). |
bun.lock |
Locks added/removed dependencies for Vitest browser mode and Playwright. |
.github/workflows/test.yml |
Installs Playwright Chromium in CI and runs tests via bun run test. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Aug 10, 2026
3 tasks
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.
Ticket
N/A — infrastructure groundwork for the selector-scoping stack (#1, #2, #4).
What are you trying to accomplish?
Run the test suite in a real browser. happy-dom restricts
querySelectorcombinator matching to the query root's subtree, which is non-spec — real browsers match document-wide and filter results to descendants. That divergence sits exactly on this library's core domain, selector resolution: the:scopeanchoring tests in #4 pass vacuously under happy-dom (verified by mutation canary — they stayed green with anchoring disabled). Landing this first means the whole stack gets verified in a real browser.What approach did you choose and why?
Vitest browser mode with the Playwright provider, all tests headless in Chromium — not a hybrid split. The library is DOM-first and tiny (33 tests on
main, ~1.2s total), so one runner/one config beats maintaining a unit/browser split; pure-logic tests run fine in the browser too.bun:test→vitest(spyOn→vi.spyOn); happy-dom,test/setup.ts, and thebunfig.tomlpreload deleted.playwrightdeclared explicitly in devDependencies (non-optional peer of@vitest/browser-playwright), sobunx playwrightmatches the provider's expectations.bunx playwright install chromium --with-deps); Bun stays as package manager/runtime.bun testdefault. Firefox/WebKit matrix deliberately skipped for now —:scopeis baseline everywhere.No changeset: test infrastructure only, no published behavior change.
Replaces #5, which GitHub's stack feature would not let retarget from
fix/scope-selectorstomain; #1/#2/#4 rebase on top of this.Verification:
bun run test33 pass in Chromium,bun run buildclean.Merge checklist
Lookbook docsn/a — npm library