Vue Testing Best Practices
Choose a Vue test harness for component behavior, async updates, stores and browser-dependent interactions.
npx skills add vuejs-ai/skills@vue-testing-best-practices What it does
A Vue component can render a stale value in a test because the assertion runs before an update settles. Vue Testing Best Practices links the symptom to the component harness and timing mechanism involved.
What changes after install
- Assert what a user can observe from a component.
- Distinguish Vue's render queue from pending promises.
- Choose a real browser for layout-sensitive behavior.
Install
Run this command with Node.js 22.20 or later and select your agent in the Skills CLI.
npx skills add vuejs-ai/skills@vue-testing-best-practices Before using Vue Testing Best Practices
- A Vue project with its test dependencies and a reproducible component interaction.
Read the reviewed setup instructions for the selected workflow.
When to use it
- Test a component that loads data after a click.
- Provide the store or lifecycle context a composable needs.
When not to use it
- Assessing a site's visual design from unit snapshots alone.
A worked example
Provide a search component that loads results after submission. Stub the request with a known result, trigger the form and assert on the rendered result text. Add a separate rejected-request case with its own visible outcome.
Troubleshooting
- For stale markup, await the Vue update.
- For unresolved network mocks, settle the promise chain.
- For missing Pinia injections, mount with the intended store configuration and decide whether actions should run or be stubbed.
How it chooses an approach
A component harness suits input and emitted events. Choose a browser test for computed layout or native interaction that a simulated DOM cannot reproduce.
When to use another skill
- Webapp Testing for checking the interaction in a running browser.
- Frontend Design for redesigning the affected view.
- Systematic Debugging for tracking a nondeterministic failure.
What to check after it runs
Run the success and error cases independently. Verify that a change to the displayed result breaks the relevant assertion even if the outer markup stays the same.
Related workflows
More in Testing
- Webapp Testing — browser interaction tests
- Systematic Debugging — root cause analysis
- Test-Driven Development — test-first implementation
- Verify Before Completion — verify completion claims
- Bats Testing Patterns — shell command tests
Related skills in other categories
FAQ
- Does a snapshot cover a user's interaction?
- Add an assertion for the observable result of the action. A matching snapshot can miss a broken transition.
- What if the agent cannot find the skill after installation?
- Check that the chosen client's skill location contains the directory and SKILL.md. Plugin registration and individual skill discovery use different installation paths.