Supercharge Cypress and Vitest testing with super-handy helpers for everything from selecting and counting elements to API mocking.
To use the library in Cypress, simply import the commands.js
into cypress/support/commands.js
. For example:
import @lewishowles/testing/src/commands.js
;
Retrieve an element by its data-test
attribute. For example [data-test="selector"]
.
Retrieve the underlying form element (input
, select
, textarea
) for a previous subject.
Retrieve the element via getByData
, then find the underlying form element.
Retrieve the underlying form element (input
, select
, textarea
) for a previous subject and fill it with the text value
.
Retrieve the element via getByData
, then find the underlying form element, and fill it with value
.
Assert that a previous form field has value
.
Assert that an element is visible.
Assert that an element is not visible.
Assert that an element has the given className
.
Assert that an element does not have the given className
.
Assert that an element has attribute
with value value
. If no value is provided, the existence of attribute
is checked.
Assert that an element does not have attribute
with value value
. If no value is provided, the existence of attribute
is checked.
Assert that there are count
elements.
Assert that an element contains the given text
(including partial matches).
Assert that an element does not contain the given text
(including partial matches).
Assert that an element has the current focus.
Assert that an element does not have the current focus.