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 docs to indicate named export should be used for userEvent #1476

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/example-findByText.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ title: Using findByText
// is not visible right away

import {screen} from '@testing-library/dom'
import userEvent from '@testing-library/user-event'
import {userEvent} from '@testing-library/user-event'
// provides a set of custom jest matchers that you can use to extend jest
// i.e. `.toBeVisible`
import '@testing-library/jest-dom'
Expand Down
2 changes: 1 addition & 1 deletion docs/example-formik.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const MyForm = ({onSubmit}) => {
// myForm.test.js
import React from 'react'
import {render, screen, waitFor} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import {userEvent} from '@testing-library/user-event'

import {MyForm} from './myForm.js'

Expand Down
4 changes: 2 additions & 2 deletions docs/example-react-router.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const App = () => (
```jsx
// app.test.js
import {render, screen} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import {userEvent} from '@testing-library/user-event'
import React from 'react'
import '@testing-library/jest-dom'
import {App, LocationDisplay} from './app'
Expand Down Expand Up @@ -175,7 +175,7 @@ so make sure you have the correct version of `history` installed.
```jsx
// app.test.js
import {render, screen} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import {userEvent} from '@testing-library/user-event'
import {createMemoryHistory} from 'history'
import React from 'react'
import {Router} from 'react-router-dom'
Expand Down
4 changes: 2 additions & 2 deletions docs/react-testing-library/example-intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ what each line does, scroll down to the

```jsx
import {render, screen} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import {userEvent} from '@testing-library/user-event'
import '@testing-library/jest-dom'
import Fetch from './fetch'

Expand All @@ -38,7 +38,7 @@ test('loads and displays greeting', async () => {
// import react-testing methods
import {render, screen} from '@testing-library/react'
// userEvent library simulates user interactions by dispatching the events that would happen if the interaction took place in a browser.
import userEvent from '@testing-library/user-event'
import {userEvent} from '@testing-library/user-event'
// add custom jest matchers from jest-dom
import '@testing-library/jest-dom'
// the component to test
Expand Down
2 changes: 1 addition & 1 deletion docs/react-testing-library/migrate-from-enzyme.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ npm install --save-dev @testing-library/user-event @testing-library/dom
Now you can import it into your test:

```jsx
import userEvent from '@testing-library/user-event'
import {userEvent} from '@testing-library/user-event'
```

To demonstrate how to use the `user-event` library, imagine we have a `Checkbox`
Expand Down
6 changes: 3 additions & 3 deletions docs/svelte-testing-library/example.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ This basic example demonstrates how to:

```js title="greeter.test.js"
import {render, screen} from '@testing-library/svelte'
import userEvent from '@testing-library/user-event'
import {userEvent} from '@testing-library/user-event'
import {expect, test} from 'vitest'

import Greeter from './greeter.svelte'
Expand Down Expand Up @@ -94,7 +94,7 @@ Consider using function props to make testing events easier.

```js title="button.test.ts"
import {render, screen} from '@testing-library/svelte'
import userEvent from '@testing-library/user-event'
import {userEvent} from '@testing-library/user-event'
import {expect, test, vi} from 'vitest'

import ButtonWithEvent from './button-with-event.svelte'
Expand Down Expand Up @@ -200,7 +200,7 @@ binding itself.

```js title="text-input.test.js"
import {render, screen} from '@testing-library/svelte'
import userEvent from '@testing-library/user-event'
import {userEvent} from '@testing-library/user-event'
import {get, writable} from 'svelte/store'
import {expect, test} from 'vitest'

Expand Down
4 changes: 2 additions & 2 deletions docs/user-event/intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ itself - e.g. in a `before`/`after` hook - for reasons described in
["Avoid Nesting When You're Testing"](https://kentcdodds.com/blog/avoid-nesting-when-youre-testing).

```js
import userEvent from '@testing-library/user-event'
import {userEvent} from '@testing-library/user-event'

// inlining
test('trigger some awesome feature when clicking the button', async () => {
Expand All @@ -80,7 +80,7 @@ test('trigger some awesome feature when clicking the button', async () => {
```

```js
import userEvent from '@testing-library/user-event'
import {userEvent} from '@testing-library/user-event'

// setup function
function setup(jsx) {
Expand Down
2 changes: 1 addition & 1 deletion docs/user-event/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This allows to write multiple consecutive interactions that behave just like the
described interactions by a real user.

```js
import userEvent from '@testing-library/user-event'
import {userEvent} from '@testing-library/user-event'

const user = userEvent.setup()

Expand Down