Skip to content

Documentation: Update async section of cheatsheet #594

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 7 commits into from
Oct 7, 2020
Merged
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
18 changes: 10 additions & 8 deletions docs/dom-testing-library/cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,21 @@ See [Which query should I use?](guide-which-query.md)

## Async

See [Async API](dom-testing-library/api-async.md)
See [Async API](dom-testing-library/api-async.md). Remember to `await` or `.then()`
the result of async functions in your tests!

- **wait** (Promise) retry the function within until it stops throwing or times
- **waitFor** (Promise) retry the function within until it stops throwing or times
out
- **waitForElement** (Promise) retry the function until it returns an element or
an array of elements
- `findBy` and `findAllBy` queries are async and retry until either a timeout
or if the query returns successfully; they wrap `waitForElement`
- **waitForDomChange** (Promise) retry the function each time the DOM is changed
- **waitForElementToBeRemoved** (Promise) retry the function until it no longer
returns a DOM node

> Remember to `await` or `.then()` the result of async functions in your tests!
> **Deprecated since v7.0.0:**
> - **wait** (Promise) retry the function within until it stops throwing or times
> - **waitForElement** (Promise) retry the function until it returns an element or
> an array of elements
> - `findBy` and `findAllBy` queries are async and retry until either a timeout
> or if the query returns successfully; they wrap `waitForElement`
> - **waitForDomChange** (Promise) retry the function each time the DOM is changed

## Events

Expand Down
16 changes: 5 additions & 11 deletions docs/react-testing-library/cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,14 @@ See [Which query should I use?](guide-which-query.md)

## Async

See [dom-testing-library Async API](dom-testing-library/api-async.md)

- **wait** (Promise) retry the function within until it stops throwing or times
out
- **waitForElement** (Promise) retry the function until it returns an element or
an array of elements
- `findBy` and `findAllBy` queries are async and retry until either a timeout
or if the query returns successfully; they wrap `waitForElement`
- **waitForDomChange** (Promise) retry the function each time the DOM is changed
The [dom-testing-library Async API](dom-testing-library/api-async.md) is
re-exported from React Testing Library.

- **waitFor** (Promise) retry the function within until it stops throwing or
times out
- **waitForElementToBeRemoved** (Promise) retry the function until it no longer
returns a DOM node

> Remember to `await` or `.then()` the result of async functions in your tests!

## Events

See [Events API](dom-testing-library/api-events.md)
Expand Down