-
Notifications
You must be signed in to change notification settings - Fork 723
docs: update user-event references #1030
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c3a01d8
docs: update user-event references
ph-fritsche c9e37cf
fix link to old docs
ph-fritsche 3467846
trigger CI
ph-fritsche 9f694d6
fix format bug
ph-fritsche d41b75d
fix format bug
ph-fritsche b6c9149
fix queries
ph-fritsche de52ec8
replace blockquote with admonition
ph-fritsche 64a0316
reverse formatting on admonition
ph-fritsche 2c22fcf
replace latest version blockquote with admonition
ph-fritsche bcfca98
fix option description
ph-fritsche 2c58bf4
fix anchor link
ph-fritsche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,14 @@ import TabItem from '@theme/TabItem' | |
advanced simulation of browser interactions than the built-in | ||
[`fireEvent`](dom-testing-library/api-events.mdx#fireevent) method. | ||
|
||
> This page describes `[email protected]`. | ||
If you are starting or actively working on a project, | ||
we recommend to use [`[email protected]`](user-event/intro.mdx) instead, as it includes important bug fixes and new features. | ||
:::caution End of life | ||
|
||
This page describes `[email protected]`. | ||
This version is no longer maintained. Please use | ||
[`user-event@14`](user-event/intro.mdx) instead, as it includes important bug | ||
fixes and new features. | ||
|
||
::: | ||
|
||
## Installation | ||
|
||
|
@@ -222,7 +227,7 @@ import {render, screen} from '@testing-library/react' | |
import userEvent from '@testing-library/user-event' | ||
|
||
test('prepend text', () => { | ||
render(<input defaultValue="World!"/>) | ||
render(<input defaultValue="World!" />) | ||
const element = screen.getByRole('textbox') | ||
|
||
// Prepend text | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,12 +63,13 @@ import {MyForm} from './myForm.js' | |
test('rendering and submitting a basic Formik form', async () => { | ||
const handleSubmit = jest.fn() | ||
render(<MyForm onSubmit={handleSubmit} />) | ||
const user = userEvent.setup() | ||
|
||
userEvent.type(screen.getByLabelText(/first name/i), 'John') | ||
userEvent.type(screen.getByLabelText(/last name/i), 'Dee') | ||
userEvent.type(screen.getByLabelText(/email/i), '[email protected]') | ||
await user.type(screen.getByLabelText(/first name/i), 'John') | ||
await user.type(screen.getByLabelText(/last name/i), 'Dee') | ||
await user.type(screen.getByLabelText(/email/i), '[email protected]') | ||
|
||
userEvent.click(screen.getByRole('button', {name: /submit/i})) | ||
await user.click(screen.getByRole('button', {name: /submit/i})) | ||
|
||
await waitFor(() => | ||
expect(handleSubmit).toHaveBeenCalledWith({ | ||
|
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
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
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
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
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
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
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
Oops, something went wrong.
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.
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'm not sure if that's even something we want to "share". If we believe that the recommended approach is to use the methods returned from
setup
, maybe this comment isn't helpful and can only cause bad practices. Wdyt?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 think it eases the transition for people who are used to the previous APIs. That's why the Direct APIs still exist.
If there is only a single API call, it makes no difference, as the Direct APIs call
.setup()
internally and then use the method from there.If it helps or hurts to mention it in the example - I don't know.
But I thought maybe mentioning it makes it sound "easier" to use.