要提醒自己稍後編寫測試,請使用 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 # 這是上一條命令的退出碼另請參閱: