Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cypress/unsafe-to-chain-command produces false positives on custom commands containing the name of an unsafe stock command #145

Open
Aryndel opened this issue Oct 4, 2023 · 2 comments
Labels

Comments

@Aryndel
Copy link

Aryndel commented Oct 4, 2023

Due to the rule code for the cypress/unsafe-to-chain-command rule simply performing a substring check for its regex test, it displays false positives for any Cypress custom commands that just happen to include the same word as a stock command the rule looks for.

For example, our repo has a custom command called checkImageMatching. Since the rule looks for the check command, it flags any commands chained from this custom command as violating the rule (for the record, the custom command just compares two image files and doesn't even query the DOM, so this isn't a concern at all).

Example code that triggers the rule inappropriately:

cy.checkImageMatching( './cypress/e2e/aya-logo-full-transparent.jpg', ${Cypress.config(
'downloadsFolder'
)}/Testjwlvh Testowszfnnb_7-1-2022 CHOCChildHealtCenteMissiViejo-1_1.jpg ).should('eq', 0);

@FDiskas
Copy link

FDiskas commented Mar 18, 2024

Also I'm getting similar on

cy.clearLocalStorage('app').should((localStorage) => {
      expect(localStorage.getItem('app')).to.be.null;
});

@tom9744
Copy link
Contributor

tom9744 commented Apr 24, 2024

I found the commit related to this issue. 49c6eb3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants