Skip to content
← Back to rules

jest/prefer-todo Style

🛠️ An auto-fix is available for this rule.

它的作用

当测试用例为空时,最好将其标记为 test.todo,因为它会在汇总输出中被高亮显示。

为什么这不好?

当使用空测试用例而不使用 test.todo 时,此规则会触发警告。

示例

以下是此规则的错误代码示例:

javascript
test("我需要写这个测试"); // 无效
test("我需要写这个测试", () => {}); // 无效
test.skip("我需要写这个测试", () => {}); // 无效

以下是此规则的正确代码示例:

javascript
test.todo("我需要写这个测试");

如何使用

To enable this rule using the config file or in the CLI, you can use:

json
{
  "plugins": ["jest"],
  "rules": {
    "jest/prefer-todo": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["jest"],
  rules: {
    "jest/prefer-todo": "error",
  },
});
bash
oxlint --deny jest/prefer-todo --jest-plugin

版本

此规则于 v0.0.16 中添加。

参考资料