jest/no-identical-title Style
它的作用
此规则会检查每个测试和测试套件的标题。 当同一测试套件层级中的两个测试套件或两个测试用例具有相同标题时,它会报告问题。
为什么这很糟糕?
为两个不同的测试或测试套件使用相同的标题可能会造成混淆。 例如,当一个与同一测试套件中另一个测试同名的测试失败时,就更难知道到底是哪个测试失败了,从而也更难修复。
示例
此规则的错误代码示例:
javascript
describe("baz", () => {
//...
});
describe("baz", () => {
// 与前一个测试套件具有相同的标题
// ...
});如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["jest"],
"rules": {
"jest/no-identical-title": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["jest"],
rules: {
"jest/no-identical-title": "error",
},
});bash
oxlint --deny jest/no-identical-title --jest-plugin版本
此规则是在 v0.0.14 中添加的。
