Locator Assertions
toBeAttached
Asserts that an element is attached to the DOM.Whether to assert that element is attached or detached.
Maximum time in milliseconds to wait for the assertion to pass.
toBeChecked
Asserts that a checkbox or radio button is checked.Whether to assert that element is checked or unchecked.
Whether to assert that element is in indeterminate state.
Maximum time in milliseconds to wait for the assertion to pass.
toBeDisabled
Asserts that an element is disabled.Maximum time in milliseconds to wait for the assertion to pass.
toBeEditable
Asserts that an element is editable.Whether to assert that element is editable or readonly.
Maximum time in milliseconds to wait for the assertion to pass.
toBeEmpty
Asserts that an element contains no text content or child elements.Maximum time in milliseconds to wait for the assertion to pass.
toBeEnabled
Asserts that an element is enabled.Whether to assert that element is enabled or disabled.
Maximum time in milliseconds to wait for the assertion to pass.
toBeFocused
Asserts that an element has focus.Maximum time in milliseconds to wait for the assertion to pass.
toBeHidden
Asserts that an element is not visible.Maximum time in milliseconds to wait for the assertion to pass.
toBeVisible
Asserts that an element is visible.Whether to assert that element is visible or hidden.
Maximum time in milliseconds to wait for the assertion to pass.
toBeInViewport
Asserts that an element is within the viewport.The minimum ratio of the element to be considered in viewport. Defaults to any positive ratio.
Maximum time in milliseconds to wait for the assertion to pass.
toContainText
Asserts that an element contains the specified text.Expected substring, pattern, or array of expected text values.
Maximum time in milliseconds to wait for the assertion to pass.
Whether to use
innerText instead of textContent.Whether to perform case-insensitive match.
toHaveAccessibleDescription
Asserts that an element has the specified accessible description.Expected accessible description.
Maximum time in milliseconds to wait for the assertion to pass.
Whether to perform case-insensitive match.
toHaveAccessibleName
Asserts that an element has the specified accessible name.Expected accessible name.
Maximum time in milliseconds to wait for the assertion to pass.
Whether to perform case-insensitive match.
toHaveAccessibleErrorMessage
Asserts that an element has the specified accessible error message.Expected accessible error message.
Maximum time in milliseconds to wait for the assertion to pass.
Whether to perform case-insensitive match.
toHaveAttribute
Asserts that an element has the specified attribute.Attribute name.
Expected attribute value.
Maximum time in milliseconds to wait for the assertion to pass.
Whether to perform case-insensitive match.
toHaveClass
Asserts that an element has the specified CSS class.Expected CSS class or array of classes.
Maximum time in milliseconds to wait for the assertion to pass.
toContainClass
Asserts that an element’s class attribute contains the specified class.Expected CSS class name or array of class names. RegExp is not supported.
Maximum time in milliseconds to wait for the assertion to pass.
toHaveCount
Asserts that a locator matches the specified number of elements.Expected number of elements.
Maximum time in milliseconds to wait for the assertion to pass.
toHaveCSS
Asserts that an element has the specified CSS property.CSS property name.
Expected CSS property value.
Object with CSS property names and their expected values.
Maximum time in milliseconds to wait for the assertion to pass.
toHaveId
Asserts that an element has the specified ID.Expected element ID.
Maximum time in milliseconds to wait for the assertion to pass.
toHaveJSProperty
Asserts that an element has the specified JavaScript property.Property name.
Expected property value.
Maximum time in milliseconds to wait for the assertion to pass.
toHaveRole
Asserts that an element has the specified ARIA role.Expected ARIA role.
Maximum time in milliseconds to wait for the assertion to pass.
Whether to perform case-insensitive match.
toHaveText
Asserts that an element has the specified text.Expected text or array of text values.
Maximum time in milliseconds to wait for the assertion to pass.
Whether to use
innerText instead of textContent.Whether to perform case-insensitive match.
toHaveValue
Asserts that an input element has the specified value.Expected input value.
Maximum time in milliseconds to wait for the assertion to pass.
toHaveValues
Asserts that a multi-select element has the specified values.Expected array of selected values.
Maximum time in milliseconds to wait for the assertion to pass.
Page Assertions
toHaveTitle
Asserts that the page has the specified title.Expected page title.
Maximum time in milliseconds to wait for the assertion to pass.
toHaveURL
Asserts that the page has the specified URL.Expected URL string, pattern, URLPattern, or predicate function.
Maximum time in milliseconds to wait for the assertion to pass.
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.Snapshot name or path segments.
Maximum time in milliseconds to wait for the assertion to pass.
How to handle CSS animations.
Whether to hide the text caret.
Area to capture.
Whether to take a full page screenshot.
Elements to mask before taking the screenshot.
Color to use for masking.
Maximum number of differing pixels allowed.
Maximum ratio of differing pixels (0-1).
Color difference threshold (0-1).
toMatchSnapshot
Asserts that a value matches the stored snapshot.Snapshot name or path segments.
Maximum number of differing pixels allowed (for images).
Maximum ratio of differing pixels (0-1, for images).
Color difference threshold (0-1, for images).
toMatchAriaSnapshot
Asserts that the accessibility tree matches the expected snapshot.Expected ARIA snapshot in YAML format.
Maximum time in milliseconds to wait for the assertion to pass.
Generic Assertions
toPass
Retries a callback until it passes without throwing an error.Function to retry until it passes.
Maximum time in milliseconds to retry.
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:Function to poll.
Maximum time in milliseconds to poll.
Polling intervals in milliseconds.
