Files
novalon-website/docs/testing/testing-guide.md
T

29 lines
617 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 测试指南
## 测试策略
本项目采用分层覆盖率策略:
- 核心业务逻辑层:70-80%覆盖率
- UI组件层:60-70%覆盖率
- 页面展示层:40-50%覆盖率
## 测试编写规范
### 单元测试
- 使用Jest和React Testing Library
- 遵循AAA模式(Arrange-Act-Assert
- 每个测试只验证一个行为
### 集成测试
- 测试组件间的交互
- 使用真实的数据流
- 避免过度mock
## 常见问题
**Q: 如何处理异步测试?**
A: 使用async/await和waitFor函数。
**Q: 如何测试错误处理?**
A: 使用toThrow和expect.assertions验证错误路径。