Run test suite in real Chromium via vitest browser mode - #5
Closed
myabc wants to merge 1 commit into
Closed
Conversation
There was a problem hiding this comment.
Pull request overview
Migrates the project’s test runner from Bun’s bun:test + happy-dom to Vitest browser mode backed by Playwright Chromium, so selector scoping behavior is validated against real browser querySelector semantics.
Changes:
- Adds Vitest browser-mode configuration (Playwright provider) and updates CI to install Chromium and run
vitest run. - Updates all test imports/spies from
bun:testtovitest(spyOn→vi.spyOn) and removes happy-dom registration/preload. - Adds an environment-guard test asserting spec-correct document-wide combinator matching.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Enables Vitest browser mode with the Playwright provider and Chromium instance. |
| test/setup.ts | Removes happy-dom global registration (no longer needed under real Chromium). |
| test/query.test.ts | Migrates test APIs to Vitest and updates commentary to reflect real-browser execution. |
| test/integration.test.ts | Migrates to Vitest APIs (vi.spyOn). |
| test/helpers.test.ts | Migrates to Vitest APIs. |
| test/harness.test.ts | Updates harness check and adds a DOM-semantics environment guard test. |
| test/element-definition.test.ts | Migrates to Vitest APIs (vi.spyOn). |
| test/blessing.test.ts | Migrates to Vitest APIs (vi.spyOn). |
| test/barrel.test.ts | Migrates to Vitest APIs. |
| package.json | Switches test script to vitest run and adds Vitest browser deps. |
| CLAUDE.md | Documents the testing exception (Vitest browser mode vs bun test). |
| bunfig.toml | Removes Bun test preload config. |
| bun.lock | Updates lockfile for Vitest/Playwright-related dependencies. |
| .github/workflows/test.yml | Installs Playwright Chromium in CI and runs the new test command. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
myabc
force-pushed
the
code-maintenance/vitest
branch
from
August 10, 2026 19:32
13ac1fb to
46a6f7d
Compare
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.
myabc
force-pushed
the
code-maintenance/vitest
branch
from
August 10, 2026 19:37
46a6f7d to
7367ed0
Compare
Collaborator
Author
|
🤖 Closing: GitHub's stack feature blocks retargeting this PR's base to main. Replaced by a standalone PR from the same branch, rewritten against main so it can land first. |
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 — follow-up to the selector-scoping work in #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: the:scopeanchoring integration tests in #4 passed vacuously (green even with anchoring disabled), and the original scoping leak was invisible to the suite.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 (60 tests, ~2.4s 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.bunx playwright install chromium --with-deps); Bun stays as package manager/runtime.bun testdefault.Proof the migration achieves its goal — mutation canary: with
anchorToScopeneutered to the identity function, the previously-vacuous anchoring tests now fail (12 failures, includingcombinators cannot match through ancestors outside the root); reverted after checking. Firefox/WebKit matrix deliberately skipped for now —:scopeis baseline everywhere.No changeset: test infrastructure only, no published behavior change.
Stacked on #4; chain #1 ← #2 ← #4 ← this.
Verification:
bun run test60 pass in Chromium,bun run typecheckclean,bun run buildclean.Merge checklist
Lookbook docsn/a — npm library