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: toHaveAccessibilityState() #124
Conversation
Codecov Report
@@ Coverage Diff @@
## main #124 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 9 10 +1
Lines 175 193 +18
Branches 57 60 +3
=========================================
+ Hits 175 193 +18
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
expect(screen.getByTestId('view')).not.toHaveAccessibilityState({ checked: false }); | ||
expect(screen.getByTestId('view')).not.toHaveAccessibilityState({ expanded: false }); |
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.
these 2 last examples confused me for a bit because we also have
expect(screen.getByTestId('view')).not.toHaveAccessibilityState({ checked: true });
expect(screen.getByTestId('view')).not.toHaveAccessibilityState({ expanded: true });
did you check for false here to contrast with the other example below?
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.
Thanks for pointing this out. I will add additional docs to explain it. Basically for checked
& expanded
having false
value is considered something different than not having value. While for disabled
, selected
and busy
not having value equal to having false
value.
Part of value proposition of this matcher is to encapsulate that behaviour.
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.
I've rewritten the docs, pls check if under current docs that makes more sense.
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.
Much clearer to me :)
@MattAgn thanks for review |
@MattAgn Could you take another look, I've addressed all your comments. |
0cbef8e
to
cea85b1
Compare
🎉 This PR is included in version 5.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What:
Matcher for matching accessiblity state, that takes into account implied state.
Why:
Current
toHaveProp
is performing strict matching ofaccessibilityState
prop, while matching based only on some state entries is useful. AdditionallytoHaveProp
is not aware of implicit state entries.How:
Calculate implied
accessibilityState
using the same rules as React Native Testing Library and match it only agains requested a11y state entries.Checklist:
@pierrezimmermannbam, @AugustinLF, @MattAgn pls take a look