-
Notifications
You must be signed in to change notification settings - Fork 40
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
fix(prefer-in-document): false positive on .toHaveLength(1) matcher with *AllBy* query #311
fix(prefer-in-document): false positive on .toHaveLength(1) matcher with *AllBy* query #311
Conversation
…bination of *By* query with .toHaveLength(1) assertion
…cher with *AllBy* query
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.
Looks good - just got a couple of nits I'd like addressed if possible
const matcherNode = node.property; | ||
|
||
const matcherArguments = node.parent.arguments; | ||
|
||
const expect = node.object.object; | ||
check({ | ||
negatedMatcher: true, | ||
queryNode: (queryNode && queryNode.callee) || queryNode, | ||
queryNode: queryNode.callee, |
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.
Codecov Report
@@ Coverage Diff @@
## main #311 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 15 15
Lines 584 602 +18
Branches 168 172 +4
=========================================
+ Hits 584 602 +18
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
🎉 This PR is included in version 5.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@G-Rath Glad to see this finally getting merged! Could you please port this fix back to v4? |
@SevenOutman the only change in v5 is that we made We don't have any infrastructure in place for doing backport releases |
Actually it's simple to do backporting with semantic-release. Just checkout a |
What:
Closes #171
Closes #273
Why:
It's valid to use .toHaveLength(1) with AllBy queries to check for "exactly one match".
See conclusion of discussions at #171 (comment)
How:
Implement the truth table as described in the link above.
Checklist:
I basically just re-pushed #273 and made a few changes to the test suite.