Vue Testing Best Practices
antfu/skills4.1k
This skill provides best practices, patterns, and solutions for testing Vue.js applications, particularly for Vue 3 projects. It covers setting up test infrastructure, component testing, mocking, handling asynchronous and complex components, and end-to-end testing with tools like Vitest and Playwright. It's ideal for developers seeking to improve their testing strategies and avoid common pitfalls in Vue.js development.
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
GitHub Owner
Owner: antfu
GitHub Links
- Twitter: https://twitter.com/antfu7
- YouTube: https://www.youtube.com/c/AnthonyFu7
- Instagram: https://www.instagram.com/antfu7
Files
testing-vitest-recommended-for-vue
testing-component-blackbox-approach
testing-async-await-flushpromises
testing-composables-helper-wrapper
testing-pinia-store-setup
testing-suspense-async-components
testing-no-snapshot-only
testing-e2e-playwright-recommended
testing-browser-vs-node-runners
async-component-testing
teleport-testing-complexity
SKILL.md
name: vue-testing-best-practices version: 1.0.0 license: MIT author: github.com/vuejs-ai description: Use for Vue.js testing. Covers Vitest, Vue Test Utils, component testing, mocking, testing patterns, and Playwright for E2E testing.
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