testing-library / cypress-testing-library

🐅 Simple and complete custom Cypress commands and utilities that encourage good testing practices.
http://npm.im/@testing-library/cypress
MIT License
1.8k stars 152 forks source link

Configuration to control the suggestions for the findByRole command #277

Open srkrish opened 2 months ago

srkrish commented 2 months ago

What you did:

Used cy.findByRole and cy.findAllByRole predominantly in my project

What happened:

When the command fails to find an accessible role, it lists all the accessible roles on the page after the term "Here are the accessible roles:"

Problem description:

Well, the suggestions are kind of agreeable when we run locally, but on a CI machine, they become really verbose. If the page has multiple accessible elements, it lists numerous options that span more than 1000 lines, making it pretty difficult to scroll and imagine this happening for multiple tests. Tried the following solution

cypress\support\e2e.js:

import { configure } from '@testing-library/cypress';

configure({ throwSuggestions: false, computedStyleSupportsPseudoElements: false, });

Suggested solution:

How to get the configuration working?