Skip to content
Merged
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
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ facilitate testing implementation details). Read more about this in
* [`cleanup`](#cleanup)
* [`Simulate`](#simulate)
* [`wait`](#wait)
* [`waitForElement`](#waitforelement)
* [`fireEvent(node: HTMLElement, event: Event)`](#fireeventnode-htmlelement-event-event)
* [`TextMatch`](#textmatch)
* [`query` APIs](#query-apis)
Expand Down Expand Up @@ -373,6 +374,39 @@ The default `interval` is `50ms`. However it will run your callback immediately
on the next tick of the event loop (in a `setTimeout`) before starting the
intervals.

### `waitForElement`

See [dom-testing-library#waitForElement](https://github.com/kentcdodds/dom-testing-library#waitforelement)

```js
await waitForElement(() => getByText('Search'))
```

<details>
<summary>
Example
</summary>

```diff
test('should submit form when valid', async () => {
const mockSubmit = jest.fn()
const {
container,
getByLabelText,
getByText
} = render(<Form onSubmit={mockSubmit} />)
const nameInput = getByLabelText('Name')
nameInput.value = 'Chewbacca'
Simulate.change(nameInput)
+ // wait for button to appear and click it
+ const submitButton = await waitForElement(() => getByText('Search'))
+ Simulate.click(submitButton)
+ expect(mockSubmit).toBeCalled()
})
```

</details>

### `fireEvent(node: HTMLElement, event: Event)`

Fire DOM events.
Expand Down