CONTRIBUTOR-DOCS / Style guide / Testing guide / Running tests
In this doc
| Purpose | Command | Notes |
|---|---|---|
| Run Storybook tests (headless) | yarn workspace @adobe/swc test |
Runs play function tests with browser |
| Run tests in UI mode | yarn workspace @adobe/swc test:ui |
Interactive Vitest UI for debugging |
| Run tests in visible browser | yarn workspace @adobe/swc test:browser |
Browser window for live debugging |
| Run tests with coverage | yarn workspace @adobe/swc test:coverage |
Generates V8 coverage report |
| Run all a11y tests | yarn test:a11y |
Both 1st-gen and 2nd-gen |
| Run 2nd-gen a11y tests | yarn test:a11y:2nd |
2nd-gen only |
| Run a11y tests with UI | yarn test:a11y:ui |
Interactive Playwright UI |
| Update ARIA snapshots | yarn test:a11y <component> --update-snapshots |
After intentional a11y tree changes |
- Storybook not running — Tests start Storybook automatically, but if it fails to start, check for port conflicts on 6006.
- Wrong story ID — Open Storybook and copy the story ID from the URL.
- Wrong element selector — Make sure the selector matches the custom element tag (e.g.,
swc-badge, notsp-badge).
- Review the diff in the test output.
- If the change is intentional, update snapshots with
--update-snapshots. - If unexpected, fix the component.
- Read the violation message and the linked docs URL.
- Fix the component to address the issue.
- Re-run to verify.
- Run
yarn workspace @adobe/swc test:coverageto see the report. - Look for uncovered lines, functions, or branches.
- Add test stories that exercise the uncovered code paths.
- Re-run coverage to confirm.
- Make sure
withWarningSpywraps the entire block where you change properties. - Call
await badge.updateCompleteafter setting properties — warnings fire during the update cycle. - If the warning is only issued once, clear
issuedWarningsby using a freshwithWarningSpyscope.