-
Notifications
You must be signed in to change notification settings - Fork 150
feat: add no-test-id-queries
rule
#1006
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
base: main
Are you sure you want to change the base?
feat: add no-test-id-queries
rule
#1006
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1006 +/- ##
==========================================
+ Coverage 96.27% 96.29% +0.01%
==========================================
Files 46 47 +1
Lines 2472 2481 +9
Branches 1025 1026 +1
==========================================
+ Hits 2380 2389 +9
Misses 92 92 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
||
## Further Reading | ||
|
||
- [about `getByTestId`](https://testing-library.com/docs/queries/bytestid) |
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.
suggestion (blocking): Please add a link to the "Not querying by text" section from "Common mistakes with React Testing Library" post.
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.
Nice, done
lib/rules/no-test-id-queries.ts
Outdated
export type MessageIds = 'noTestIdQueries'; | ||
type Options = []; | ||
|
||
const QUERIES_REGEX = /^(get|query|getAll|queryAll|find|findAll)ByTestId$/; |
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.
suggestion (blocking): Please build this regex using the ALL_QUERIES_VARIANTS
from the utils file.
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.
Good idea, done
]; | ||
|
||
ruleTester.run(RULE_NAME, rule, { | ||
valid: [ |
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.
suggestion (blocking): Please add another valid test that includes calls to methods containing *TestId
at the end but not matching the regex reported by the rule (e.g. caculateTestId
, getTestId
, searchByTestId
)
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.
Done
Closes #279