Skip to content
Testing

Vue Testing Best Practices

Choose a Vue test harness for component behavior, async updates, stores and browser-dependent interactions.

Install with Skills CLI
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.

Install with 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

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.

More in Testing

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.