name: vue-testing-best-practices version: 1.0.0 license: MIT author: github.com/vuejs-ai description: 用于Vue.js测试。涵盖Vitest、Vue Test Utils、组件测试、模拟、测试模式以及用于端到端测试的Playwright。
Vue.js 测试最佳实践、模式和常见陷阱。
测试
- 为Vue 3项目设置测试基础设施 → 参见 testing-vitest-recommended-for-vue
- 测试在重构组件内部时不断中断 → 参见 testing-component-blackbox-approach
- 测试因竞争条件间歇性失败 → 参见 testing-async-await-flushpromises
- 使用生命周期钩子或注入的组合函数无法测试 → 参见 testing-composables-helper-wrapper
- 在测试中获取“injection Symbol(pinia) not found”错误 → 参见 testing-pinia-store-setup
- 具有异步设置的组件在测试中无法渲染 → 参见 testing-suspense-async-components
- 快照测试尽管功能中断仍继续通过 → 参见 testing-no-snapshot-only
- 为Vue应用选择端到端测试框架 → 参见 testing-e2e-playwright-recommended
- 测试需要验证计算样式或真实DOM事件 → 参见 testing-browser-vs-node-runners
- 使用defineAsyncComponent创建的组件测试失败 → 参见 async-component-testing
- 传送的模态内容无法在包装器查询中找到 → 参见 teleport-testing-complexity