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
12 changes: 7 additions & 5 deletions docs/react-testing-library/example-intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test('loads and displays greeting', async () => {
await waitFor(() => screen.getByRole('heading'))

expect(screen.getByRole('heading')).toHaveTextContent('hello there')
expect(screen.getByRole('button')).toHaveAttribute('disabled')
expect(screen.getByRole('button')).toBeDisabled()
})

test('handles server error', async () => {
Expand All @@ -52,7 +52,7 @@ test('handles server error', async () => {
await waitFor(() => screen.getByRole('alert'))

expect(screen.getByRole('alert')).toHaveTextContent('Oops, failed to fetch!')
expect(screen.getByRole('button')).not.toHaveAttribute('disabled')
expect(screen.getByRole('button')).not.toBeDisabled()
})
```

Expand Down Expand Up @@ -158,11 +158,13 @@ await waitFor(() =>
### Assert

```jsx
// assert that the alert message is correct.
// assert that the alert message is correct using
// toHaveTextContent, a custom matcher from jest-dom.
expect(screen.getByRole('alert')).toHaveTextContent('Oops, failed to fetch!')

// assert that the button is not disabled.
expect(screen.getByRole('button')).not.toHaveAttribute('disabled')
// assert that the button is not disabled using
// toBeDisabled, a custom matcher from jest-dom.
expect(screen.getByRole('button')).not.toBeDisabled()
```

### System Under Test
Expand Down