首页/ AI 技能 / @skilllib/skill-2117939930272412718
Skill站外收录 @skilllib/skill-2117939930272412718

testing

支持使用 Vitest v4 构建单元与集成双模式测试体系,涵盖模块模拟、Zustand 状态管理器验证及交互功能端到端连通性检查,确保代码逻辑与 UI 行为严格一致。

0.0 (0) 31 次安装 原作者 编程导航
收录于 2026-01-22
测试与安全 AI 技能

Skills.MD

# Testing Write reliable tests with Vitest v4 dual configuration. ## Activation Conditions - Writing or modifying tests - Debugging test failures - Setting up mocks - Questions about test configuration ## Quick Reference | Action | Rule | |--------|------| | Choose test type | `test-unit-vs-integration.md` | | Mock modules | `test-mock-patterns.md` | | Test stores | `test-zustand-stores.md` | | Mock Connect APIs | `mock-transport.md` | | Skip UI rendering tests | `no-ui-rendering-tests.md` | ## Commands ```bash bun run test # All tests (CI default) bun run test:ci # Sequential for CI bun run test:unit # Unit tests only bun run test:integration # Integration tests only bun run test:ui # Interactive UI bun run test:watch # Watch mode bun run test:coverage # Coverage report ``` ## Key Points - `.test.ts` = unit (Node.js), `.test.tsx` = integration (JSDOM) - Always use `test-utils/test-utils.tsx` for React component tests - Test that features are fully wired: UI elements must connect to actual functionality ### Feature Completeness Testing When implementing interactive features (buttons, forms, etc.): - Verify event handlers call the correct functions with proper parameters - Test that AbortSignals, callbacks, and other "plumbing" are passed through - Don't assume UI presence means functionality works - test the connection ## When to Use This Skill - Writing `.test.ts` or `.test.tsx` files - Mocking modules, stores, or transports - Component behavior tests **NOT for:** Multi-page user workflows → use [e2e-tester](../e2e-tester/SKILL.md) ## Rules See `rules/` directory for detailed guidance.

评论 0

还没有评论,来抢沙发。