jest/no-identical-title 风格
它做了什么
此规则检查每个测试和测试套件的标题。 当同一层级的两个测试套件或两个测试用例具有相同标题时,将报告错误。
为什么这是不好的?
为两个不同的测试或测试套件设置相同的标题可能会引起混淆。 例如,当一个与同级测试套件中另一个测试具有相同标题的测试失败时,更难判断是哪一个失败了,因此也更难修复。
示例
此规则的 错误 代码示例:
javascript
describe("baz", () => {
//...
});
describe("baz", () => {
// 与之前的测试套件具有相同标题
// ...
});该规则与 eslint-plugin-vitest 兼容, 要使用它,请在你的 .oxlintrc.json 中添加以下配置:
json
{
"rules": {
"vitest/no-identical-title": "error"
}
}如何使用
要通过配置文件或命令行 启用 此规则,可以使用:
json
{
"plugins": ["jest"],
"rules": {
"jest/no-identical-title": "error"
}
}bash
oxlint --deny jest/no-identical-title --jest-plugin