测试能力与 bun test
Bun 自带 test runner,这让很多项目在看它时,不会只停在 bun install。
最基础的命令
bun test
bun test --watch
bun test --coverage
官方测试文档里,比较值得注意的是这些能力:
- watch mode
- snapshots
- DOM 测试
- coverage
- retry
- timeout
- reporter
适合先从哪类项目试
- 工具库
- 脚本仓库
- 纯前端辅助包
- 新项目
如果项目已经深度依赖 Jest 或 Vitest 的特定生态,迁前最好先跑真实用例,而不是只跑 hello world。
配置入口
官方文档里提到:
- CLI 参数
bunfig.toml
也就是说,测试配置既可以放命令行,也可以集中在配置文件里。