工具
Jest 快速参考
Jest 快速参考 的可打印速查表,适合快速查阅、学习和桌边参考
示例
速查表包含什么
- 配置
- 基础测试
- 断言(Matchers)
- 异步测试
- 模拟(Mocking)
- 间谍(Spies)
- 快照(Snapshots)
- Setup & Teardown
- 配置选项
- 常见模式
安装
npm install --save-dev jest
# package.json: "scripts": { "test": "jest" }
npx jest # run all tests
npx jest --watch # re-run on changes
文件命名
*.test.js | 测试文件(默认匹配模式) |
*.spec.js | 备用测试文件模式 |
__tests__/ | 测试目录(自动发现) |
运行指定测试
npx jest path/to/file.test.js
npx jest --testNamePattern="adds"
npx jest --verbose # detailed output
下载完整速查表,获取所有章节的打印排版版本
下载 PDF下载