要提醒自己稍后编写测试,请使用 test.todo 函数。无需提供测试实现。
ts
import { test, expect } from "bun:test";
// 稍后编写这个
test.todo("未实现的功能");bun test 的输出指示遇到了多少个 todo 测试。
sh
bun testtxt
test.test.ts:
✓ add [0.03ms]
✓ multiply [0.02ms]
✎ unimplemented feature
2 pass
1 todo
0 fail
2 expect() calls
Ran 3 tests across 1 files. [74.00ms]可选地,你可以提供测试实现。
ts
import { test, expect } from "bun:test";
test.todo("未实现的功能", () => {
expect(Bun.isAwesome()).toBe(true);
});如果提供了实现,除非传递 --todo 标志,否则不会运行它。如果传递了 --todo 标志,测试将被执行并且测试运行器期望失败!如果 todo 测试通过,bun test 运行将返回非零退出码以表示失败。
sh
bun test --todotxt
my.test.ts:
✗ unimplemented feature
^ 此测试标记为 todo 但通过了。移除 `.todo` 或检查测试是否正确。
0 pass
1 fail
1 expect() calls
$ echo $?
1 # 这是上一条命令的退出码另请参阅: