用于 Vue.js 测试。涵盖 Vitest、Vue Test Utils、组件测试、模拟、测试模式以及用于 E2E 测试的 Playwright。
Resources
1Install
npx skillscat add hello-lizhihua/skills-zh-cn/vue-testing-best-practices Install via the SkillsCat registry.
SKILL.md
Vue.js 测试最佳实践、模式和常见陷阱。
测试
- 为 Vue 3 项目设置测试基础设施 → 参见 testing-vitest-recommended-for-vue
- 重构组件内部时测试不断中断 → 参见 testing-component-blackbox-approach
- 由于竞争条件,测试间歇性失败 → 参见 testing-async-await-flushpromises
- 使用生命周期钩子或 inject 的可组合函数无法测试 → 参见 testing-composables-helper-wrapper
- 在测试中遇到 "injection Symbol(pinia) not found" 错误 → 参见 testing-pinia-store-setup
- 带有异步 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 的模态框内容 → 参见 teleport-testing-complexity