Skip to content

Commit f439b7c

Browse files
Update guide-disappearance.md (testing-library#412)
Update to mention `waitFor` as it will replace `wait` and change `waitForElement` example to use `findBy` query instead.
1 parent f1fa42e commit f439b7c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/guide-disappearance.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ test('movie title appears', async () => {
1717
// element is initially not present...
1818

1919
// wait for appearance
20-
await wait(() => {
20+
await waitFor(() => {
2121
expect(getByText('the lion king')).toBeInTheDocument()
2222
})
2323

2424
// wait for appearance and return the element
25-
const movie = await waitForElement(() => getByText('the lion king'))
25+
const movie = await findByText('the lion king')
2626
})
2727
```
2828

@@ -41,9 +41,9 @@ test('movie title no longer present in DOM', async () => {
4141

4242
Using
4343
[`MutationObserver`](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver)
44-
is more efficient than polling the DOM at regular intervals with `wait`.
44+
is more efficient than polling the DOM at regular intervals with `waitFor`.
4545

46-
The `wait` [async helper][async-api] function retries until the wrapped function
46+
The `waitFor` [async helper][async-api] function retries until the wrapped function
4747
stops throwing an error. This can be used to assert that an element disappears
4848
from the page.
4949

@@ -52,7 +52,7 @@ test('movie title goes away', async () => {
5252
// element is initially present...
5353
// note use of queryBy instead of getBy to return null
5454
// instead of throwing in the query itself
55-
await wait(() => {
55+
await waitFor(() => {
5656
expect(queryByText('i, robot')).not.toBeInTheDocument()
5757
})
5858
})

0 commit comments

Comments
 (0)