docs(frontend): Note that tests should render a component, not a renderFoo() helper - #19570
Merged
Merged
Conversation
…erFoo() helper A local renderFoo() helper hides the JSX from every test that calls it, and it breaks rerender, which takes an element. The tip sits with the other RTL tips and shows the Example component shape we want instead.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
ryan953
marked this pull request as ready for review
September 22, 2026 20:17
The tip was longer than the tips around it. A generic Widget makes the same point in half the space.
Contributor
|
Please update the IS YOUR CHANGE URGENT? section of the PR description:
This information helps the Docs team prioritize your review. |
natemoo-re
approved these changes
Sep 22, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a tip to the "Using React Testing Library" page: render the component under test, rather than wrapping
render()in a localrenderFoo()helper.The helper is common in
getsentry/sentryspecs and hides the JSX from every test that calls it, so a reader has to go find the helper before anit()block makes sense. Each file also invents its own name and argument shape for the same idea. The tip shows theExampleFoocomponent shape we want instead, and sits with the other tips on the page.It calls out the part that actually breaks:
rerendertakes an element, so with a helper the call site no longer controls what is rendered. Passing a different root component type torerenderremounts the tree and silently drops the state the test was checking. That is not a hypothetical — converting 42 spec files in getsentry/sentry#125144 surfaced exactly this in two tests.The tip also names what is not this pattern, so it does not read as a ban on all test helpers: a helper that only registers
MockApiClientmocks, or one that takes the element to render as a parameter, is fine as it is.Related
no-custom-render-helperscanner convention and the matching note in the repo'sreact-testingskill.