Skip to content

Commit cfecbff

Browse files
authored
Sync docs with latest dom-testing-library (testing-library#418)
1 parent e5fcd43 commit cfecbff

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
queryByTestId,
1515
// Tip: all queries are also exposed on an object
1616
// called "queries" which you could import here as well
17-
wait,
17+
waitFor,
1818
} from '@testing-library/dom'
1919
// adds special assertions like toHaveTextContent
2020
import '@testing-library/jest-dom/extend-expect'
@@ -57,7 +57,7 @@ test('examples of some things', async () => {
5757
// Get elements by their text, just like a real user does.
5858
getByText(container, 'Print Username').click()
5959

60-
await wait(() =>
60+
await waitFor(() =>
6161
expect(queryByTestId(container, 'printed-username')).toBeTruthy()
6262
)
6363

docs/example-react-router.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,23 @@ test('rendering a component that uses withRouter', () => {
8787

8888
## Reducing boilerplate
8989

90-
1. You can use the `wrapper` option to wrap a `MemoryRouter` around the component you want to render (`MemoryRouter` works when you don't need access to the history object itself in the test, but just need the components to be able to render and navigate).
90+
1. You can use the `wrapper` option to wrap a `MemoryRouter` around the
91+
component you want to render (`MemoryRouter` works when you don't need access
92+
to the history object itself in the test, but just need the components to be
93+
able to render and navigate).
9194

9295
```jsx
9396
import { MemoryRouter } from 'react-router-dom'
9497

9598
test('full app rendering/navigating', () => {
96-
const { container, getByText } = render(<App />, {wrapper: MemoryRouter})
99+
const { container, getByText } = render(<App />, { wrapper: MemoryRouter })
97100
// verify page content for expected route
98101
expect(getByRole('heading')).toMatch('Home')
99102
})
100103
```
101104

102-
2. If you find yourself adding Router components to your tests a lot, you may want to create
103-
a helper function that wraps around `render`.
105+
2. If you find yourself adding Router components to your tests a lot, you may
106+
want to create a helper function that wraps around `render`.
104107

105108
```jsx
106109
// test utils file
@@ -111,9 +114,11 @@ function renderWithRouter(
111114
history = createMemoryHistory({ initialEntries: [route] }),
112115
} = {}
113116
) {
114-
const Wrapper = ({children}) => <Router history={history}>{children}</Router>
117+
const Wrapper = ({ children }) => (
118+
<Router history={history}>{children}</Router>
119+
)
115120
return {
116-
...render(ui, {wrapper: Wrapper}),
121+
...render(ui, { wrapper: Wrapper }),
117122
// adding `history` to the returned utilities to allow us
118123
// to reference it in our tests (just try to avoid using
119124
// this to test implementation details).
@@ -137,4 +142,3 @@ test('rendering a component that uses withRouter', () => {
137142
expect(getByTestId('location-display')).toHaveTextContent(route)
138143
})
139144
```
140-

docs/pptr-testing-library/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const $email = await getByLabelText($form, 'Email')
3232
// interact with puppeteer like usual
3333
await $email.type('pptr@example.com')
3434
// waiting works too!
35-
await wait(() => getByText('Loading...'))
35+
await waitFor(() => getByText('Loading...'))
3636
```
3737

3838
A little too un-puppeteer for you? You can attach all the `DOM Testing Library`

0 commit comments

Comments
 (0)