mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
66 lines
3.0 KiB
Markdown
66 lines
3.0 KiB
Markdown
---
|
|
title: Assertion API | Browser Mode
|
|
---
|
|
|
|
# Assertion API
|
|
|
|
Vitest bundles [`@testing-library/jest-dom`](https://github.com/testing-library/jest-dom) library to provide a wide range of DOM assertions out of the box. For detailed documentation, you can read the `jest-dom` readme:
|
|
|
|
- [`toBeDisabled`](https://github.com/testing-library/jest-dom#toBeDisabled)
|
|
- [`toBeEnabled`](https://github.com/testing-library/jest-dom#toBeEnabled)
|
|
- [`toBeEmptyDOMElement`](https://github.com/testing-library/jest-dom#toBeEmptyDOMElement)
|
|
- [`toBeInTheDocument`](https://github.com/testing-library/jest-dom#toBeInTheDocument)
|
|
- [`toBeInvalid`](https://github.com/testing-library/jest-dom#toBeInvalid)
|
|
- [`toBeRequired`](https://github.com/testing-library/jest-dom#toBeRequired)
|
|
- [`toBeValid`](https://github.com/testing-library/jest-dom#toBeValid)
|
|
- [`toBeVisible`](https://github.com/testing-library/jest-dom#toBeVisible)
|
|
- [`toContainElement`](https://github.com/testing-library/jest-dom#toContainElement)
|
|
- [`toContainHTML`](https://github.com/testing-library/jest-dom#toContainHTML)
|
|
- [`toHaveAccessibleDescription`](https://github.com/testing-library/jest-dom#toHaveAccessibleDescription)
|
|
- [`toHaveAccessibleErrorMessage`](https://github.com/testing-library/jest-dom#toHaveAccessibleErrorMessage)
|
|
- [`toHaveAccessibleName`](https://github.com/testing-library/jest-dom#toHaveAccessibleName)
|
|
- [`toHaveAttribute`](https://github.com/testing-library/jest-dom#toHaveAttribute)
|
|
- [`toHaveClass`](https://github.com/testing-library/jest-dom#toHaveClass)
|
|
- [`toHaveFocus`](https://github.com/testing-library/jest-dom#toHaveFocus)
|
|
- [`toHaveFormValues`](https://github.com/testing-library/jest-dom#toHaveFormValues)
|
|
- [`toHaveStyle`](https://github.com/testing-library/jest-dom#toHaveStyle)
|
|
- [`toHaveTextContent`](https://github.com/testing-library/jest-dom#toHaveTextContent)
|
|
- [`toHaveValue`](https://github.com/testing-library/jest-dom#toHaveValue)
|
|
- [`toHaveDisplayValue`](https://github.com/testing-library/jest-dom#toHaveDisplayValue)
|
|
- [`toBeChecked`](https://github.com/testing-library/jest-dom#toBeChecked)
|
|
- [`toBePartiallyChecked`](https://github.com/testing-library/jest-dom#toBePartiallyChecked)
|
|
- [`toHaveRole`](https://github.com/testing-library/jest-dom#toHaveRole)
|
|
- [`toHaveErrorMessage`](https://github.com/testing-library/jest-dom#toHaveErrorMessage)
|
|
|
|
If you are using TypeScript or want to have correct type hints in `expect`, make sure you have either `@vitest/browser/providers/playwright` or `@vitest/browser/providers/webdriverio` specified in your `tsconfig` depending on the provider you use. If you use the default `preview` provider, you can specify `@vitest/browser/matchers` instead.
|
|
|
|
::: code-group
|
|
```json [preview]
|
|
{
|
|
"compilerOptions": {
|
|
"types": [
|
|
"@vitest/browser/matchers"
|
|
]
|
|
}
|
|
}
|
|
```
|
|
```json [playwright]
|
|
{
|
|
"compilerOptions": {
|
|
"types": [
|
|
"@vitest/browser/providers/playwright"
|
|
]
|
|
}
|
|
}
|
|
```
|
|
```json [webdriverio]
|
|
{
|
|
"compilerOptions": {
|
|
"types": [
|
|
"@vitest/browser/providers/webdriverio"
|
|
]
|
|
}
|
|
}
|
|
```
|
|
:::
|