Skip to content
← Back to rules

vitest/no-disabled-tests 正确性

作用

此规则会对被禁用的测试发出警告。

为什么这不好?

Jest 提供了一项功能,允许你临时将测试标记为禁用。这个 功能在调试时或为未来的测试创建占位符时通常很有帮助。在提交更改之前,我们可能希望检查所有测试 都在运行。

示例

js
describe.skip("foo", () => {});
it.skip("foo", () => {});
test.skip("foo", () => {});

describe["skip"]("bar", () => {});
it["skip"]("bar", () => {});
test["skip"]("bar", () => {});

xdescribe("foo", () => {});
xit("foo", () => {});
xtest("foo", () => {});

it("bar");
test("bar");

it("foo", () => {
  pending();
});

如何使用

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

json
{
  "plugins": ["vitest"],
  "rules": {
    "vitest/no-disabled-tests": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["vitest"],
  rules: {
    "vitest/no-disabled-tests": "error",
  },
});
bash
oxlint --deny vitest/no-disabled-tests --vitest-plugin

版本

此规则在 v0.0.7 中加入。

参考资料