Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 763 Bytes

require-data-selectors.md

File metadata and controls

23 lines (18 loc) · 763 Bytes

Only allow data-* attribute selectors (require-data-selectors)

only allow cy.get to allow selectors that target data-* attributes

See the Cypress Best Practices guide.

Note: If you use this rule, consider only using the warn error level, since using data-* attribute selectors may not always be possible.

Rule Details

examples of incorrect code with require-data-selectors:

cy.get(".a")
cy.get('[daedta-cy=submit]').click()
cy.get('[d-cy=submit]')
cy.get(".btn-large").click()
cy.get(".btn-.large").click()

examples of correct code with require-data-selectors:

cy.get('[data-cy=submit]').click()
cy.get('[data-QA=submit]')