若要提醒自己稍後撰寫測試,請使用 test.todo
函式。無需提供測試實作。
import { test, expect } from "bun:test";
// write this later
test.todo("unimplemented feature");
bun test
的輸出會指出遇到多少個 todo
測試。
bun test
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]
或者,你可以提供測試實作。
import { test, expect } from "bun:test";
test.todo("unimplemented feature", () => {
expect(Bun.isAwesome()).toBe(true);
});
如果提供實作,測試執行器會執行該實作並預期會失敗!如果待辦事項測試通過,bun test
執行會傳回非零結束代碼以表示失敗。
bun test
echo $?
1 # this is the exit code of the previous command
另請參閱