Skip to content

Commit 341f41e

Browse files
Replace waitForElement to waitFor (#416)
1 parent 2fdf844 commit 341f41e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/react-testing-library/example-intro.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ See the following sections for a detailed breakdown of the test
1111
```jsx
1212
// __tests__/fetch.test.js
1313
import React from 'react'
14-
import { render, fireEvent, waitForElement, screen } from '@testing-library/react'
14+
import { render, fireEvent, waitFor, screen } from '@testing-library/react'
1515
import '@testing-library/jest-dom/extend-expect'
1616
import axiosMock from 'axios'
1717
import Fetch from '../fetch'
@@ -28,7 +28,7 @@ test('loads and displays greeting', async () => {
2828

2929
fireEvent.click(screen.getByText('Load Greeting'))
3030

31-
await waitForElement(() => screen.getByRole('heading'))
31+
await waitFor(() => screen.getByRole('heading'))
3232

3333
expect(axiosMock.get).toHaveBeenCalledTimes(1)
3434
expect(axiosMock.get).toHaveBeenCalledWith(url)
@@ -48,7 +48,7 @@ test('loads and displays greeting', async () => {
4848
import React from 'react'
4949

5050
// import react-testing methods
51-
import { render, fireEvent, waitForElement, screen } from '@testing-library/react'
51+
import { render, fireEvent, waitFor, screen } from '@testing-library/react'
5252

5353
// add custom jest matchers from jest-dom
5454
import '@testing-library/jest-dom/extend-expect'
@@ -91,9 +91,9 @@ fireEvent.click(getByText('Load Greeting'))
9191

9292
// Wait until the mocked `get` request promise resolves and
9393
// the component calls setState and re-renders.
94-
// `waitForElement` waits until the callback doesn't throw an error
94+
// `waitFor` waits until the callback doesn't throw an error
9595

96-
await waitForElement(() =>
96+
await waitFor(() =>
9797
// getByRole throws an error if it cannot find an element
9898
screen.getByRole('heading')
9999
)

0 commit comments

Comments
 (0)