Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

minsoo-web
Copy link

This page is based on v14, so I think it should use named import.

Copy link

netlify bot commented Nov 4, 2024

Deploy Preview for testing-library ready!

Name Link
🔨 Latest commit 2820068
🔍 Latest deploy log https://app.netlify.com/sites/testing-library/deploys/67286d094c713e000891ee37
😎 Deploy Preview https://deploy-preview-1446--testing-library.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@MatanBobi
Copy link
Member

@ph-fritsche Any chance to get your look at this one? I remember we had some issues with that named import?

@ahayes91
Copy link

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!

@ph-fritsche
Copy link
Member

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants