-
-
Couldn't load subscription status.
- Fork 31
feat(unique-test-case-names): add rule to enforce unique test case name #561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(unique-test-case-names): add rule to enforce unique test case name #561
Conversation
This change adds a new rule to require that any test cases that have names defined, have unique names within each `valid` and `invalid` group. This helps ensure that test logs are unambiguous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new ESLint rule unique-test-case-names that enforces unique test case names within valid and invalid test groups. This helps ensure test logs are unambiguous by preventing duplicate names that could make it difficult to identify failing tests.
Key Changes:
- Implements the
unique-test-case-namesrule that validates test case name uniqueness within each test group - Adds comprehensive test coverage for the new rule, including edge cases like shorthand strings and unnamed test cases
- Integrates the rule into the plugin's rule registry and documentation
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/rules/unique-test-case-names.ts | Implements the core rule logic that tracks seen names and reports duplicates |
| tests/lib/rules/unique-test-case-names.ts | Provides test coverage for valid and invalid test case name scenarios |
| lib/index.ts | Registers the new rule in the plugin's rule collection |
| docs/rules/unique-test-case-names.md | Documents the rule's purpose, examples, and usage guidelines |
| README.md | Adds the rule to the plugin's rule listing table |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) { | ||
| const name = property.value.value; | ||
| if (namesSeen.has(name)) { | ||
| violatingNodes.push(property.value); |
Copilot
AI
Oct 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only duplicate occurrences are tracked, but the first occurrence of a duplicate name is not reported. When a duplicate is found, both the original and duplicate nodes should be reported. Consider tracking nodes associated with each name to report all duplicates, including the first occurrence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was intentional. I was treating the first occurrence as ok, but report every duplicate after. But maybe all should be reported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a pattern for that kind of thing in other rules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
This change adds a new rule to require that any test cases that have names defined, have unique names within each
validandinvalidgroup. This helps ensure that test logs are unambiguous.Closes #554