-
Notifications
You must be signed in to change notification settings - Fork 728
Update intro.mdx import #1446
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
Update intro.mdx import #1446
Conversation
✅ Deploy Preview for testing-library ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@ph-fritsche Any chance to get your look at this one? I remember we had some issues with that named import?
ahayes91
commented
Mar 24, 2025
Might be worth using this PR to update a few other places referencing v14 - https://github.com/testing-library/testing-library-docs/pull/1476/files has some examples!
I'm not sure...
- Direct APIs will be deprecated and removed at some point.
- Preparing the document is necessary and giving users the option to call this (and cleanup callbacks) at any point might solve compatibility issues with other frameworks/tools. feat: export callbacks for hooks user-event#1270
- A test that reuses old pointer/keyboard state might be confusing. Therefore we should keep on recommending to call
setup()
inside the test. Using a setup function that combines this with render function of the respecting framework gives a clean and concise test code.
// current recommendation according to docs import userEvent, {PointerEventsCheckLevel} from '@testing-library/user-event' const user = userEvent.setup() await user.setup({pointerEventsCheck: PointerEventsCheckLevel.Never}).click() // also possible, but not officially recommended import { userEvent, PointerEventsCheckLevel} from '@testing-library/user-event'
If we expose prepare
, reset
and detach
with the next version, we could also expose setup
as named export.
import {setup, PointerEventsCheckLevel} from '@testing-library/user-event' // or if the user prefers import * as userEvent from '@testing-library/user-event'
This page is based on v14, so I think it should use named import.