// Disable automatic exports.
import { ARIARole } from './aria-role.ts'
export interface TestingLibraryMatchers {
/**
* @description
* Assert whether an element is present in the document or not.
* @example
*
*
* await expect.element(page.getByTestId('svg-element')).toBeInTheDocument()
* await expect.element(page.getByTestId('does-not-exist')).not.toBeInTheDocument()
* @see https://vitest.dev/guide/browser/assertion-api#tobeinthedocument
*/
toBeInTheDocument(): R
/**
* @description
* This allows you to check if an element is currently visible to the user.
*
* An element is visible if **all** the following conditions are met:
* * it does not have its css property display set to none
* * it does not have its css property visibility set to either hidden or collapse
* * it does not have its css property opacity set to 0
* * its parent element is also visible (and so on up to the top of the DOM tree)
* * it does not have the hidden attribute
* * if `` it has the open attribute
* @example
*
* Zero Opacity
*
*
*
Visible Example
*
* await expect.element(page.getByTestId('zero-opacity')).not.toBeVisible()
* await expect.element(page.getByTestId('visible')).toBeVisible()
* @see https://vitest.dev/guide/browser/assertion-api#tobevisible
*/
toBeVisible(): R
/**
* @description
* Assert whether an element has content or not.
* @example
*
*
*
*
* await expect.element(page.getByTestId('empty')).toBeEmptyDOMElement()
* await expect.element(page.getByTestId('not-empty')).not.toBeEmptyDOMElement()
* @see https://vitest.dev/guide/browser/assertion-api#tobeemptydomelement
*/
toBeEmptyDOMElement(): R
/**
* @description
* Allows you to check whether an element is disabled from the user's perspective.
*
* Matches if the element is a form control and the `disabled` attribute is specified on this element or the
* element is a descendant of a form element with a `disabled` attribute.
* @example
*
*
* await expect.element(page.getByTestId('button')).toBeDisabled()
* @see https://vitest.dev/guide/browser/assertion-api#tobedisabled
*/
toBeDisabled(): R
/**
* @description
* Allows you to check whether an element is not disabled from the user's perspective.
*
* Works like `not.toBeDisabled()`.
*
* Use this matcher to avoid double negation in your tests.
* @example
*
*
* await expect.element(page.getByTestId('button')).toBeEnabled()
* @see https://vitest.dev/guide/browser/assertion-api#tobeenabled
*/
toBeEnabled(): R
/**
* @description
* Check if a form element, or the entire `form`, is currently invalid.
*
* An `input`, `select`, `textarea`, or `form` element is invalid if it has an `aria-invalid` attribute with no
* value or a value of "true", or if the result of `checkValidity()` is false.
* @example
*
*
*
*
* await expect(page.getByTestId('no-aria-invalid')).not.toBeInvalid()
* await expect(page.getByTestId('invalid-form')).toBeInvalid()
* @see https://vitest.dev/guide/browser/assertion-api#tobeinvalid
*/
toBeInvalid(): R
/**
* @description
* This allows you to check if a form element is currently required.
*
* An element is required if it is having a `required` or `aria-required="true"` attribute.
* @example
*
*
*
* await expect.element(page.getByTestId('required-input')).toBeRequired()
* await expect.element(page.getByTestId('supported-role')).not.toBeRequired()
* @see https://vitest.dev/guide/browser/assertion-api#toberequired
*/
toBeRequired(): R
/**
* @description
* Allows you to check if a form element is currently required.
*
* An `input`, `select`, `textarea`, or `form` element is invalid if it has an `aria-invalid` attribute with no
* value or a value of "false", or if the result of `checkValidity()` is true.
* @example
*
*
*
*
* await expect.element(page.getByTestId('no-aria-invalid')).not.toBeValid()
* await expect.element(page.getByTestId('invalid-form')).toBeInvalid()
* @see https://vitest.dev/guide/browser/assertion-api#tobevalid
*/
toBeValid(): R
/**
* @description
* Allows you to assert whether an element contains another element as a descendant or not.
* @example
*
*
*
*
* const ancestor = page.getByTestId('ancestor')
* const descendant = page.getByTestId('descendant')
* const nonExistentElement = page.getByTestId('does-not-exist')
* await expect.element(ancestor).toContainElement(descendant)
* await expect.element(descendant).not.toContainElement(ancestor)
* await expect.element(ancestor).not.toContainElement(nonExistentElement)
* @see https://vitest.dev/guide/browser/assertion-api#tocontainelement
*/
toContainElement(element: HTMLElement | SVGElement | null): R
/**
* @description
* Assert whether a string representing a HTML element is contained in another element.
* @example
*
*
* const parent = page.getByTestId('parent')
* await expect.element(parent).toContainHTML('')
* @see https://vitest.dev/guide/browser/assertion-api#tocontainhtml
*/
toContainHTML(htmlText: string): R
/**
* @description
* Allows you to check if a given element has an attribute or not.
*
* You can also optionally check that the attribute has a specific expected value or partial match using
* [expect.stringContaining](https://jestjs.io/docs/en/expect.html#expectnotstringcontainingstring) or
* [expect.stringMatching](https://jestjs.io/docs/en/expect.html#expectstringmatchingstring-regexp).
* @example
*
*
* await expect.element(button).toHaveAttribute('disabled')
* await expect.element(button).toHaveAttribute('type', 'submit')
* await expect.element(button).not.toHaveAttribute('type', 'button')
* @see https://vitest.dev/guide/browser/assertion-api#tohaveattribute
*/
toHaveAttribute(attr: string, value?: unknown): R
/**
* @description
* Check whether the given element has certain classes within its `class` attribute.
*
* You must provide at least one class, unless you are asserting that an element does not have any classes.
* @example
*
*
*
no classes
*
* const deleteButton = page.getByTestId('delete-button')
* const noClasses = page.getByTestId('no-classes')
* await expect.element(deleteButton).toHaveClass('btn')
* await expect.element(deleteButton).toHaveClass('btn-danger xs')
* await expect.element(deleteButton).toHaveClass(/danger/, 'xs')
* await expect.element(deleteButton).toHaveClass('btn xs btn-danger', {exact: true})
* await expect.element(deleteButton).not.toHaveClass('btn xs btn-danger', {exact: true})
* await expect.element(noClasses).not.toHaveClass()
* @see https://vitest.dev/guide/browser/assertion-api#tohaveclass
*/
toHaveClass(...classNames:
| (string | RegExp)[]
| [string, options?: {exact: boolean}]
| [string, string, options?: {exact: boolean}]
| [string, string, string, options?: {exact: boolean}]
| [string, string, string, string, options?: {exact: boolean}]
| [string, string, string, string, string, options?: {exact: boolean}]
| [string, string, string, string, string, string, options?: {exact: boolean}]
| [string, string, string, string, string, string, string, options?: {exact: boolean}]
| [string, string, string, string, string, string, string, string, options?: {exact: boolean}]
| [string, string, string, string, string, string, string, string, string, options?: {exact: boolean}]
): R
/**
* @description
* This allows you to check whether the given form element has the specified displayed value (the one the
* end user will see). It accepts ,
*
*
*
* await expect.element(page.getByTestId('img-alt')).toHaveAccessibleName('Test alt')
* await expect.element(page.getByTestId('img-empty-alt')).not.toHaveAccessibleName()
* await expect.element(page.getByTestId('svg-title')).toHaveAccessibleName('Test title')
* await expect.element(page.getByTestId('button-img-alt')).toHaveAccessibleName()
* await expect.element(page.getByTestId('img-paragraph')).not.toHaveAccessibleName()
* await expect.element(page.getByTestId('svg-button')).toHaveAccessibleName()
* await expect.element(page.getByTestId('svg-without-title')).not.toHaveAccessibleName()
* await expect.element(page.getByTestId('input-title')).toHaveAccessibleName()
* @see https://vitest.dev/guide/browser/assertion-api#tohaveaccessiblename
*/
toHaveAccessibleName(text?: string | RegExp | E): R
/**
* @description
* This allows you to assert that an element has the expected
* [role](https://www.w3.org/TR/html-aria/#docconformance).
*
* This is useful in cases where you already have access to an element via
* some query other than the role itself, and want to make additional
* assertions regarding its accessibility.
*
* The role can match either an explicit role (via the `role` attribute), or
* an implicit one via the [implicit ARIA
* semantics](https://www.w3.org/TR/html-aria/).
*
* Note: roles are matched literally by string equality, without inheriting
* from the ARIA role hierarchy. As a result, querying a superclass role
* like 'checkbox' will not include elements with a subclass role like
* 'switch'.
*
* @example
*
*
Continue
*
* About
* Invalid link
*
* await expect.element(page.getByTestId('button')).toHaveRole('button')
* await expect.element(page.getByTestId('button-explicit')).toHaveRole('button')
* await expect.element(page.getByTestId('button-explicit-multiple')).toHaveRole('button')
* await expect.element(page.getByTestId('button-explicit-multiple')).toHaveRole('switch')
* await expect.element(page.getByTestId('link')).toHaveRole('link')
* await expect.element(page.getByTestId('link-invalid')).not.toHaveRole('link')
* await expect.element(page.getByTestId('link-invalid')).toHaveRole('generic')
*
* @see https://vitest.dev/guide/browser/assertion-api#tohaverole
*/
toHaveRole(
// Get autocomplete for ARIARole union types, while still supporting another string
// Ref: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-567871939
role: ARIARole | (string & {}),
): R
/**
* @description
* This allows you to check whether the given element is partially checked.
* It accepts an input of type checkbox and elements with a role of checkbox
* with a aria-checked="mixed", or input of type checkbox with indeterminate
* set to true
*
* @example
*
*
*
*
*
*
*
* const ariaCheckboxMixed = getByTestId('aria-checkbox-mixed')
* const inputCheckboxChecked = getByTestId('input-checkbox-checked')
* const inputCheckboxUnchecked = getByTestId('input-checkbox-unchecked')
* const ariaCheckboxChecked = getByTestId('aria-checkbox-checked')
* const ariaCheckboxUnchecked = getByTestId('aria-checkbox-unchecked')
* const inputCheckboxIndeterminate = getByTestId('input-checkbox-indeterminate')
*
* await expect.element(ariaCheckboxMixed).toBePartiallyChecked()
* await expect.element(inputCheckboxChecked).not.toBePartiallyChecked()
* await expect.element(inputCheckboxUnchecked).not.toBePartiallyChecked()
* await expect.element(ariaCheckboxChecked).not.toBePartiallyChecked()
* await expect.element(ariaCheckboxUnchecked).not.toBePartiallyChecked()
*
* inputCheckboxIndeterminate.indeterminate = true
* await expect.element(inputCheckboxIndeterminate).toBePartiallyChecked()
* @see https://vitest.dev/guide/browser/assertion-api#tobepartiallychecked
*/
toBePartiallyChecked(): R
/**
* @description
* This allows to assert that an element has a
* [text selection](https://developer.mozilla.org/en-US/docs/Web/API/Selection).
*
* This is useful to check if text or part of the text is selected within an
* element. The element can be either an input of type text, a textarea, or any
* other element that contains text, such as a paragraph, span, div etc.
*
* NOTE: the expected selection is a string, it does not allow to check for
* selection range indeces.
*
* @example
*
*
*
*
prev
*
text selected text
*
next
*
*
* page.getByTestId('text').element().setSelectionRange(5, 13)
* await expect.element(page.getByTestId('text')).toHaveSelection('selected')
*
* page.getByTestId('textarea').element().setSelectionRange(0, 5)
* await expect.element('textarea').toHaveSelection('text ')
*
* const selection = document.getSelection()
* const range = document.createRange()
* selection.removeAllRanges()
* selection.empty()
* selection.addRange(range)
*
* // selection of child applies to the parent as well
* range.selectNodeContents(page.getByTestId('child').element())
* await expect.element(page.getByTestId('child')).toHaveSelection('selected')
* await expect.element(page.getByTestId('parent')).toHaveSelection('selected')
*
* // selection that applies from prev all, parent text before child, and part child.
* range.setStart(page.getByTestId('prev').element(), 0)
* range.setEnd(page.getByTestId('child').element().childNodes[0], 3)
* await expect.element(page.queryByTestId('prev')).toHaveSelection('prev')
* await expect.element(page.queryByTestId('child')).toHaveSelection('sel')
* await expect.element(page.queryByTestId('parent')).toHaveSelection('text sel')
* await expect.element(page.queryByTestId('next')).not.toHaveSelection()
*
* // selection that applies from part child, parent text after child and part next.
* range.setStart(page.getByTestId('child').element().childNodes[0], 3)
* range.setEnd(page.getByTestId('next').element().childNodes[0], 2)
* await expect.element(page.queryByTestId('child')).toHaveSelection('ected')
* await expect.element(page.queryByTestId('parent')).toHaveSelection('ected text')
* await expect.element(page.queryByTestId('prev')).not.toHaveSelection()
* await expect.element(page.queryByTestId('next')).toHaveSelection('ne')
*
* @see https://vitest.dev/guide/browser/assertion-api#tohaveselection
*/
toHaveSelection(selection?: string): R
}