test: spike Vitest browser mode as WTR replacement#1299
Conversation
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
2 similar comments
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
ace783a to
dcd57f7
Compare
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
dcd57f7 to
e93a2cb
Compare
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
1 similar comment
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
f4f335e to
9377f8b
Compare
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
5 similar comments
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
Replace Web Test Runner with Vitest 4 browser mode + vitest-browser-lit for the button and input component test suites (81 tests). - Add Vitest config with Playwright chromium browser provider - Convert button.test.ts and input.test.ts to vitest-browser-lit - Add axe-core custom matcher (vitest-axe incompatible with browser mode) - Add src/internal/test/a11y.ts helper for axe runs - Remove WTR config and all @open-wc/testing dependencies - Update CI workflow for Vitest - Exclude vitest.setup.ts and vite.config.ts from build tsconfig - Restrict test include to converted files only (spike scope) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Full migration of test suite from @open-wc/testing + WTR to vitest-browser-lit + Vitest 4. All 809 tests pass (3 skipped), total runtime ~8.5s (down from ~45s with WTR). Key changes: - fixture() -> render().container.querySelector() - Chai assertions -> Vitest expect() - @open-wc/testing imports -> vitest-browser-lit - UUITestMouse uses userEvent.click() from @vitest/browser/context - done() callbacks converted to async/await with Promises - Conversion script at scripts/convert-tests.mjs for reference Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The convert-tests.mjs script was used during the WTR → Vitest migration and is no longer needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Matches the previous WTR behavior: Chromium only locally, all 3 browsers on CI via process.env.CI check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Firefox returns subpixel scrollTop/scrollLeft values (e.g. 42.316 instead of 42). Use Math.round() for cross-browser compatibility. Also fix Assertion type augmentation generic for toHaveNoViolations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ontext Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
19b274e to
1e3ea22
Compare
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
There was a problem hiding this comment.
Pull request overview
This PR migrates the test infrastructure from Web Test Runner (WTR) with @open-wc/testing to Vitest 4 browser mode. The migration converts all 80 test files (809 tests) to use vitest-browser-lit for rendering and Vitest's Jest-compatible assertions. Performance is improved by approximately 2x (warm runs: ~10s vs ~20s). The migration includes a custom axe-core accessibility matcher, replaces the oneEvent helper, and updates CI to run tests across Chromium, Firefox, and WebKit browsers.
Changes:
- Replaces WTR + Mocha + Chai testing stack with Vitest 4 browser mode
- Migrates all test files to use
render()from vitest-browser-lit and Vitest assertions - Implements custom
toHaveNoViolations()matcher for axe-core accessibility testing
Reviewed changes
Copilot reviewed 90 out of 92 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| web-test-runner.config.js | Removed WTR configuration file |
| vitest.setup.ts | New custom matcher for accessibility testing |
| vite.config.ts | Added Vitest configuration with browser mode |
| tsconfig.json | Updated types to include Vitest globals and browser |
| package.json | Updated dependencies and test scripts |
| .github/workflows/tests.yml | Updated CI to install Playwright browsers |
| src/internal/test/index.ts | Simplified mouse helper using userEvent |
| src/internal/test/a11y.ts | New axe-core wrapper for accessibility testing |
| src/internal/version.test.ts | Sample migration showing before/beforeAll changes |
| src/components/*/**.test.ts | Migrated all 80 component test files |
Removes 32 duplicate oneEvent() definitions from individual test files and exports it from src/internal/test/index.ts instead. Also narrows lint-staged tsc-files glob to *.element.ts to avoid type-checking test files in pre-commit (they lack the vitest setup context that provides custom matchers). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |
|
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1299.westeurope.azurestaticapps.net |



Summary
Spike for AB#65042 — evaluate Vitest as a replacement for Web Test Runner.
Full migration of all 80 component test files from
@open-wc/testing+ WTR tovitest-browser-lit+ Vitest 4 browser mode.@open-wc/testingand WTR dependenciesPerformance (local, Chromium only, same machine)
Vitest is roughly ~2x faster on warm runs. The variance comes from Vite's dependency pre-bundling cache — cold starts are slower, cached runs are fast. Actual test execution is consistently ~5s in Vitest.
Key findings
@web/test-runner+ Mocha + Chaivitest+@vitest/browser@open-wc/testingfixture()vitest-browser-litrender()@open-wc/testing.accessible()axe-coredirect + custom matcher@web/test-runner-commandssendMouse@vitest/browser/contextuserEvent.click()@open-wc/testing.shadowDom.toBe()Migration patterns
render(html...).container.querySelector('tag')!replacesfixture(html...)await element.updateCompletereplaceselementUpdated(element)vitest-axedoes not work in browser mode — useaxe-coredirectly with a custom matcherdone()callbacks → async/await with Promises.to.equal()→.toBe(),.to.have.property()→.toHaveProperty(), etc.UUITestMousenow usesuserEvent.click()from@vitest/browser/contextdescribe()blocks error in Vitest ("No test found in suite")Manual fixes needed beyond script
lit/static-html.js+ manual fixturedone()callback pattern → Promise-baseddescribeinsideit(Vitest forbids this)shadowDom.toBe()→ behavioral assertionsfixture()calls missed by script.querySelector('.active')+ doubleupdateComplete.to.false,.to.undefined) — silently pass but don't assertTest plan
npx vitest run— 809 tests pass, 3 skipped, 80 files🤖 Generated with Claude Code