cypress-io / eslint-plugin-cypress

An ESLint plugin for projects that use Cypress

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cypress/unsafe-to-chain-command errors being throw for wait with alias (v2.13.1)

tgdevereux opened this issue · comments

With the latest version of eslint-plugin-cypress, version 2.13.1, cypress/unsafe-to-chain-command lint errors appear to be getting thrown for wait commands that chain commands from it, when wait is given an alias argument.

Based on the Cypress docs here, it is unsafe to chain further commands that rely on the subject after .wait(), when given a time argument. However, it doesn't say it is unsafe when given an alias argument, as that would be used to wait and return a response from a request, for use in the test.

Based on the above, should the cypress/unsafe-to-chain-command not be getting applied to wait commands with alias arguments?

Running into this same issue with the cy.wait command and the new rule.

https://docs.cypress.io/api/commands/wait even includes examples such as:

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

and

cy.wait('@userPut').its('request.url').should('include', 'users')

Here's a PR to solve the issue: #128

commented

I just merged that PR and the build should publish the latest shortly. I am going to close this issue for the time being. Please comment back if the latest version doesn't resolve your issue.

The PR and new release does fix the issue. Rather than not applying the rule to any cy.wait commands, however, it would be great if it was still applied to non-alias cy.wait commands.

commented

Hi @patrickcate , Can you open a new feature request for that please?

@nagash77, done with: #131