You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is more of a feature request than a bug report. We use cypress/require-data-selectors in our Cypress test suite and it's helped us a lot. However, there is a case where it can be annoying.
Say you have a keyboard shortcut on the page you are testing, for example pressing "Escape" will close a modal pop-up. We'll write a cypress test like this:
cy.get("body").type("{esc}");
But this is flagged as an error by cypress/require-data-selectors. However I would argue that adding a data-selector on <body> is kind of counter-productive, as HTML spec specifies that:
In conforming documents, there is only one body element.
Since there can be only one <body> in my document, why should I identify it with another data-attribute ?
Therefore I propose to make an exception and allow cy.get("body") with this rule. Currently, we are "working around" the errors by using aliases so that the error will only have to be disabled once instead of everywhere on the page:
// eslint-disable-next-line cypress/require-data-selectorscy.get("body").as("body");//...cy.get("@body");// Aliases are allowed
What do you think about that ?
I can write a pull request for that if you agree with the proposal.
Have a nice day ! :)
The text was updated successfully, but these errors were encountered:
This is more of a feature request than a bug report. We use
cypress/require-data-selectors
in our Cypress test suite and it's helped us a lot. However, there is a case where it can be annoying.Say you have a keyboard shortcut on the page you are testing, for example pressing "Escape" will close a modal pop-up. We'll write a cypress test like this:
But this is flagged as an error by
cypress/require-data-selectors
. However I would argue that adding a data-selector on<body>
is kind of counter-productive, as HTML spec specifies that:Since there can be only one
<body>
in my document, why should I identify it with another data-attribute ?Therefore I propose to make an exception and allow
cy.get("body")
with this rule. Currently, we are "working around" the errors by using aliases so that the error will only have to be disabled once instead of everywhere on the page:What do you think about that ?
I can write a pull request for that if you agree with the proposal.
Have a nice day ! :)
The text was updated successfully, but these errors were encountered: