-
Notifications
You must be signed in to change notification settings - Fork 44
fix: toHaveTextContent supports interpolated variables #59
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: toHaveTextContent supports interpolated variables #59
Conversation
Codecov Report
@@ Coverage Diff @@
## master #59 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 8 8
Lines 96 147 +51
Branches 28 48 +20
=========================================
+ Hits 96 147 +51
Continue to review full report at Codecov.
|
@jeremyshearer thanks for opening this PR. Looks good, I just left a comment. |
Co-authored-by: Bruno Castro <[email protected]>
I was about to comment in #52 that it didn't worked for interpolated variables, but you've already fixed it XD I'm not sure if it helps, but this change works for me :D |
@brunohkbx Thanks for taking a look! I have applied your excellent suggestion. Please let me know if you see anything else that needs to happen to get this merged in. |
Hi @jeremyshearer. I'm afraid we won't be able to merge this until we move from travis to github actions I'll try to take a look at it today and starts a draft |
🎉 This PR is included in version 4.0.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
What:
Fix a bug where text content that gets split into an array does not get evaluated by the
toHaveTextContent
matcher.Why:
There's a test case in the PR, but this test case currently fails in master:
How:
The bug was in treating all array elements as react nodes that had a path of
['props', 'children']
that could be traversed to get the text content. The fix is to pass the element directly into the recursivegetText
call and let the conditional logic determine how to extract the text.Checklist:
docs N/A