cypress-io / eslint-plugin-cypress

An ESLint plugin for projects that use Cypress

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add `unsafe-to-chain-command` exception for `cy.wait` command when used with alias.

patrickcate opened this issue · comments

As mentioned in #127 (comment), one exception to the unsafe-to-chain-command rule is cy.wait when used with an alias:

// Example: assert status from cy.intercept() before proceeding
cy.wait('@alias').its('response.statusCode').should('eq', 200)

Currently the unsafe-to-chain-command is turned off for all cy.wait commands. Instead it would be most useful if the rule was applied for cy.wait commands unless they as used with an alias.

Example:

// BAD
cy.wait(5000);

// GOOD
cy.wait('@alias');
commented

@patrickcate thank you for entering your request. We will review your request internally and decide if this is something we would be interested in implementing.

Came here and found this issue because my team also ran into a situation like this where I'm trying to enforce better practices of using aliases for wait rather than hard-coded numbers. I would love to be able to add a warning for the pattern of wait(Number) instead of wait(String).