Locator Assertions
toBeAttached
Asserts that an element is attached to the DOM.boolean
default:"true"
Whether to assert that element is attached or detached.
number
Maximum time in milliseconds to wait for the assertion to pass.
toBeChecked
Asserts that a checkbox or radio button is checked.boolean
Whether to assert that element is checked or unchecked.
boolean
Whether to assert that element is in indeterminate state.
number
Maximum time in milliseconds to wait for the assertion to pass.
toBeDisabled
Asserts that an element is disabled.number
Maximum time in milliseconds to wait for the assertion to pass.
toBeEditable
Asserts that an element is editable.boolean
default:"true"
Whether to assert that element is editable or readonly.
number
Maximum time in milliseconds to wait for the assertion to pass.
toBeEmpty
Asserts that an element contains no text content or child elements.number
Maximum time in milliseconds to wait for the assertion to pass.
toBeEnabled
Asserts that an element is enabled.boolean
default:"true"
Whether to assert that element is enabled or disabled.
number
Maximum time in milliseconds to wait for the assertion to pass.
toBeFocused
Asserts that an element has focus.number
Maximum time in milliseconds to wait for the assertion to pass.
toBeHidden
Asserts that an element is not visible.number
Maximum time in milliseconds to wait for the assertion to pass.
toBeVisible
Asserts that an element is visible.boolean
default:"true"
Whether to assert that element is visible or hidden.
number
Maximum time in milliseconds to wait for the assertion to pass.
toBeInViewport
Asserts that an element is within the viewport.number
The minimum ratio of the element to be considered in viewport. Defaults to any positive ratio.
number
Maximum time in milliseconds to wait for the assertion to pass.
toContainText
Asserts that an element contains the specified text.string | RegExp | Array<string | RegExp>
required
Expected substring, pattern, or array of expected text values.
number
Maximum time in milliseconds to wait for the assertion to pass.
boolean
Whether to use
innerText instead of textContent.boolean
Whether to perform case-insensitive match.
toHaveAccessibleDescription
Asserts that an element has the specified accessible description.string | RegExp
required
Expected accessible description.
number
Maximum time in milliseconds to wait for the assertion to pass.
boolean
Whether to perform case-insensitive match.
toHaveAccessibleName
Asserts that an element has the specified accessible name.string | RegExp
required
Expected accessible name.
number
Maximum time in milliseconds to wait for the assertion to pass.
boolean
Whether to perform case-insensitive match.
toHaveAccessibleErrorMessage
Asserts that an element has the specified accessible error message.string | RegExp
required
Expected accessible error message.
number
Maximum time in milliseconds to wait for the assertion to pass.
boolean
Whether to perform case-insensitive match.
toHaveAttribute
Asserts that an element has the specified attribute.string
required
Attribute name.
string | RegExp
Expected attribute value.
number
Maximum time in milliseconds to wait for the assertion to pass.
boolean
Whether to perform case-insensitive match.
toHaveClass
Asserts that an element has the specified CSS class.string | RegExp | Array<string | RegExp>
required
Expected CSS class or array of classes.
number
Maximum time in milliseconds to wait for the assertion to pass.
toContainClass
Asserts that an element’s class attribute contains the specified class.string | string[]
required
Expected CSS class name or array of class names. RegExp is not supported.
number
Maximum time in milliseconds to wait for the assertion to pass.
toHaveCount
Asserts that a locator matches the specified number of elements.number
required
Expected number of elements.
number
Maximum time in milliseconds to wait for the assertion to pass.
toHaveCSS
Asserts that an element has the specified CSS property.string
CSS property name.
string | RegExp
Expected CSS property value.
Record<string, string>
Object with CSS property names and their expected values.
number
Maximum time in milliseconds to wait for the assertion to pass.
toHaveId
Asserts that an element has the specified ID.string | RegExp
required
Expected element ID.
number
Maximum time in milliseconds to wait for the assertion to pass.
toHaveJSProperty
Asserts that an element has the specified JavaScript property.string
required
Property name.
any
required
Expected property value.
number
Maximum time in milliseconds to wait for the assertion to pass.
toHaveRole
Asserts that an element has the specified ARIA role.string
required
Expected ARIA role.
number
Maximum time in milliseconds to wait for the assertion to pass.
boolean
Whether to perform case-insensitive match.
toHaveText
Asserts that an element has the specified text.string | RegExp | Array<string | RegExp>
required
Expected text or array of text values.
number
Maximum time in milliseconds to wait for the assertion to pass.
boolean
Whether to use
innerText instead of textContent.boolean
Whether to perform case-insensitive match.
toHaveValue
Asserts that an input element has the specified value.string | RegExp
required
Expected input value.
number
Maximum time in milliseconds to wait for the assertion to pass.
toHaveValues
Asserts that a multi-select element has the specified values.Array<string | RegExp>
required
Expected array of selected values.
number
Maximum time in milliseconds to wait for the assertion to pass.
Page Assertions
toHaveTitle
Asserts that the page has the specified title.string | RegExp
required
Expected page title.
number
Maximum time in milliseconds to wait for the assertion to pass.
toHaveURL
Asserts that the page has the specified URL.string | RegExp | URLPattern | (url: URL) => boolean
required
Expected URL string, pattern, URLPattern, or predicate function.
number
Maximum time in milliseconds to wait for the assertion to pass.
boolean
Whether to perform case-insensitive match.
API Response Assertions
toBeOK
Asserts that an API response has a successful status code (200-299).Snapshot Assertions
toHaveScreenshot
Asserts that a page or locator screenshot matches the stored snapshot.string | string[]
Snapshot name or path segments.
number
Maximum time in milliseconds to wait for the assertion to pass.
'disabled' | 'allow'
How to handle CSS animations.
'hide' | 'initial'
Whether to hide the text caret.
{ x: number, y: number, width: number, height: number }
Area to capture.
boolean
Whether to take a full page screenshot.
Locator[]
Elements to mask before taking the screenshot.
string
Color to use for masking.
number
Maximum number of differing pixels allowed.
number
Maximum ratio of differing pixels (0-1).
number
Color difference threshold (0-1).
toMatchSnapshot
Asserts that a value matches the stored snapshot.string | string[]
Snapshot name or path segments.
number
Maximum number of differing pixels allowed (for images).
number
Maximum ratio of differing pixels (0-1, for images).
number
Color difference threshold (0-1, for images).
toMatchAriaSnapshot
Asserts that the accessibility tree matches the expected snapshot.string
Expected ARIA snapshot in YAML format.
number
Maximum time in milliseconds to wait for the assertion to pass.
Generic Assertions
toPass
Retries a callback until it passes without throwing an error.() => void | Promise<void>
required
Function to retry until it passes.
number
Maximum time in milliseconds to retry.
number[]
Retry intervals in milliseconds.
Negation
All matchers can be negated using.not:
Soft Assertions
Soft assertions don’t terminate test execution:Polling
Poll a function and make assertions on its return value:() => any
required
Function to poll.
number
Maximum time in milliseconds to poll.
number[]
Polling intervals in milliseconds.
