Cypress-resq
cypress react element select query
Install
npm i -S cypress-resq
Configure Cypress
before use it, please add plugin and commands to cypress
Plugin
Find your cypress/plugins/index.js
file and change it to look like this:
const injectResqPlugin = ; // add this line module { ; // add this line};
Command
Find your cypress/support/index.js
file and add the following line:
;
Usage
Basic usage
Take this React App
// imports const MyComponent = <div>My Component</div> const App = <div><MyComponent /></div> ReactDOM
Selecting MyComponent
and click it by cypress:
// it's important to inject resq command after visit react page.cy;// find element by react component namecy;
Filtering selection
You can filter your selections by props
<MyComponent e2e="goodcomponent" />
Selecting MyComponent
with prop e2e and click it by cypress:
cy;
Chain selection
you can chain resq$
command after others command return element.
cy;