jest/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();
});此规则与 eslint-plugin-vitest 兼容。要使用它,请将以下配置添加到您的 .oxlintrc.json 文件中:
json
{
"rules": {
"vitest/no-disabled-tests": "error"
}
}如何使用
要通过配置文件或命令行 启用 此规则,可以使用:
json
{
"plugins": ["jest"],
"rules": {
"jest/no-disabled-tests": "error"
}
}bash
oxlint --deny jest/no-disabled-tests --jest-plugin