要提醒自己稍后编写测试,请使用 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
另请参阅