docs: prefer userEvent in unit test examples#34632
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughDocumentation updates replace Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @rohanadepu, Due to a recent high volume of unreviewed AI-generated PRs, we are requesting verification and proof that the implemented fix actually works. Please provide a simple GIF/Video or image of how the fix works, optimally with before-and-after comparisons. Thank you for your understanding! |
|
Hi @valentinpalkovic, absolutely. Thanks for explaining. Here is a quick VS Code capture showing the before/after diff for the affected docs snippet: This PR is docs-only. The relevant change is replacing the I also verified locally with:
|
kylegach
left a comment
There was a problem hiding this comment.
Thanks, @rohanadepu! Appreciate it. 🙂

What
Update the stories-in-unit-tests examples to prefer
userEvent.setup()andawait user.click(...)overfireEvent.click(...).Why
Testing Library recommends
userEventfor interactions that model user behavior. This also makes the unit-test examples more consistent with Storybook interaction testing, whereuserEventis provided to play functions.How
fireEventimports/usages in the unit-test snippets with@testing-library/user-eventscreenqueries in the unit-test examples because composed stories run inside the external test rendererscreenvs thecanvasqueries provided to play functionsIssue
Fixes #31868
Validation
corepack yarn docs:checkcorepack yarn fmt:check docs/_snippets/component-test-with-testing-library.md docs/_snippets/single-story-test.md docs/_snippets/multiple-stories-test.md docs/writing-tests/integrations/stories-in-unit-tests.mdxSummary by CodeRabbit
fireEvent.click()with@testing-library/user-eventfor improved interaction testing.screenfor provided examples andcanvasqueries within storyplayfunctions.