-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix up custom render + rerender samples #226
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 up custom render + rerender samples #226
Conversation
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 looks great! Thanks! Let's just see if we can improve the formatting a bit.
README.md
Outdated
@@ -11,16 +11,23 @@ | |||
<hr /> | |||
|
|||
[![Build Status][build-badge]][build] | |||
|
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.
Did prettier add these extra lines here? If so, could you put them all on a single line? Otherwise the badges will no longer be side-by-side and will instead take up their own lives which will not look good.
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.
Indeed. Yes, I did flag exactly that up in the PR comment. I'm guessing that whoever previously modified the README.md
previously skipped the prettier step. I'll go back and put them on a single line.
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'll need to remove the blank lines and add 'prettier ignore' markup. For the issue links, pre-commit/prettier automatically splits them onto separate lines, and then on a subsequent commit adds blank lines between them.
The get/query methods in the "how to override data-testid" sample were not `.bind`ing correctly; I've replaced them with arrow functions as suggested. They were also passing in `container`, which wasn't correct. Also, a `rerender` implementation is needed in such a custom renderer, so I've added one to the sample. I've also fixed up the separate custom rerender sample as it a) incorrectly advertised an options parameter, and b) didn't pass along the original baseElement. For: testing-library#225
8048df5
to
d7c45f8
Compare
I've fought prettier and won. Revised PR with a cleaner set of changes. |
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.
Thank you!
🎉 This PR is included in version 5.3.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
I was searching for how to customize |
Hi @mbest, this is what you want: https://testing-library.com/docs/react-testing-library/setup#custom-render |
Thanks for the pointer. I did get the example from here to work, but the I was specifically searching for how to get |
@mbest, I think that |
I don't think he was trying to override the rerender method. He just wanted re-render to work nicely without having to specify any wrapping components again. |
Oh, my bad, didn't get that 👍 Sorry. |
What:
This fixes the samples mentioned in issue #225.
Why:
The code samples in the
README.md
were incorrect.How:
I built my own custom renderer, and once I was happy that it was working, I backported the changes to the
README.md
.Checklist:
Note that there are a few blank lines added to the
README.md
, a couple of which change the formatting (e.g. around the issue links in the data-testid section). These were inserted by the repository's ownpre-commit
hook (presumably runningprettier
or some such?).