Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
vuejs-ai avatar

Vue Testing Best Practices

  • 8k installs
  • 2.8k repo stars
  • Updated May 30, 2026
  • vuejs-ai/skills

This is a copy of vue-testing-best-practices by antfu - installs and ranking accrue to the original listing.

Vue Testing Best Practices is a Vue 3 testing skill that teaches correct async component testing with `flushPromises` for developers who need reliable Vitest specs for `defineAsyncComponent` without false-negative assert

About

Vue Testing Best Practices is a vuejs-ai skill flagged HIGH impact for a common Vue 3 testing gotcha: assertions on async components created with `defineAsyncComponent` run before the component finishes loading. The skill mandates `await flushPromises()` inside `async/await` Vitest tests so Vue's asynchronous update cycle completes before expectations execute. Without this pattern, tests report false negatives even when components render correctly in the browser. Developers reach for Vue Testing Best Practices when writing or debugging Vitest specs for lazy-loaded or async Vue 3 components.

  • 5-point task checklist for testing async Vue components
  • Guides proper use of await flushPromises() after mounting defineAsyncComponent
  • Demonstrates testing of loading states, error states, and trigger events
  • Shows exactly why tests fail without awaiting Vue's async DOM updates
  • Hard-gate: always await flushPromises before assertions on async components

Vue Testing Best Practices by the numbers

  • 8,046 all-time installs (skills.sh)
  • +155 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/vuejs-ai/skills --skill vue-testing-best-practices

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs8k
repo stars2.8k
Security audit3 / 3 scanners passed
Last updatedMay 30, 2026
Repositoryvuejs-ai/skills

How do you test Vue 3 async components in Vitest?

Correctly test Vue 3 async components and avoid false negatives caused by un-awaited rendering.

Who is it for?

Vue 3 developers writing Vitest tests for async or lazy-loaded components who see assertions firing before render completes.

Skip if: Developers testing purely synchronous Vue components that do not use `defineAsyncComponent` or async data loading.

When should I use this skill?

Vitest tests for Vue 3 `defineAsyncComponent` fail intermittently or assert before the component has rendered.

What you get

Reliable Vitest test specs with `flushPromises`-awaited assertions that pass for `defineAsyncComponent` lazy-loaded units.

  • corrected Vitest spec files

By the numbers

  • Marked HIGH impact for async component testing gotchas

Files

SKILL.mdMarkdownGitHub ↗

Vue.js testing best practices, patterns, and common gotchas.

Testing

  • Setting up test infrastructure for Vue 3 projects → See testing-vitest-recommended-for-vue
  • Tests keep breaking when refactoring component internals → See testing-component-blackbox-approach
  • Tests fail intermittently with race conditions → See testing-async-await-flushpromises
  • Composables using lifecycle hooks or inject fail to test → See testing-composables-helper-wrapper
  • Getting "injection Symbol(pinia) not found" errors in tests → See testing-pinia-store-setup
  • Components with async setup won't render in tests → See testing-suspense-async-components
  • Snapshot tests keep passing despite broken functionality → See testing-no-snapshot-only
  • Choosing end-to-end testing framework for Vue apps → See testing-e2e-playwright-recommended
  • Tests need to verify computed styles or real DOM events → See testing-browser-vs-node-runners
  • Testing components created with defineAsyncComponent fails → See async-component-testing
  • Teleported modal content can't be found in wrapper queries → See teleport-testing-complexity

Reference

Related skills

FAQ

Why do Vue 3 async component tests fail without flushPromises?

Vue Testing Best Practices explains that `defineAsyncComponent` loads asynchronously while Vitest assertions run synchronously by default. Without `await flushPromises()`, tests assert before Vue finishes rendering, causing false negatives.

What is the recommended pattern for testing async Vue components?

Vue Testing Best Practices recommends `async/await` Vitest functions with `await flushPromises()` before each assertion on components created via `defineAsyncComponent`. This waits for Vue's update cycle to complete.

Is Vue Testing Best Practices safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Testing & QAfrontendtesting

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.