question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

await-async-utils false positive on chained cy.wait().its().then()

See original GitHub issue

Plugin version

v5.1.0

ESLint version

v8.12.0

Node.js version

16.14.0

npm/yarn version

npm 8.3.1

Operating system

macOS Big Sur 11.6

Bug description

cy.wait getting picked up by testing-library/await-async-utils on a line like…

    cy.wait(`@${label}`, { timeout: 1000 * 60 * 3 })
      .its('status')
      .then(status => expect(status).to.be.oneOf([200, 304]));

The rule documentation says chaining is ok. I assume it’s the its that’s complicating things.

Thanks!

Steps to reproduce

Got to get back to work. I hope this helps. Thanks!

Error output/screenshots

No response

ESLint configuration

Got to get back to work. I hope this helps. Thanks!

Rule(s) affected

testing-library/await-async-utils

Anything else?

Thank you!

Do you want to submit a pull request to fix this bug?

No

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Belco90commented, Apr 29, 2022

@cburgmer that was our original approach, but that would discard reporting related to Testing Library coming from non “testing-library” modules. It’s pretty common to re-export Testing Library utils from a custom module (e.g. “test-utils”). The plugin wouldn’t be aware of it. That’s why we have this Aggressive Reporting in place, leaving it up to you to narrow the scope with ESLint settings or the plugin settings.

You can read more about it here: https://github.com/testing-library/eslint-plugin-testing-library/issues/198

1reaction
cburgmercommented, Apr 28, 2022

Could we re-open and find a better solution? After all this plugin seems to be very fuzzy at looking for occurrences of findByRole and similar functions used in testing-library. This could lead to errors in other implementations unrelated to testing-library as well.

Currently indeed this is necessary in your .eslintrc:

{
  "plugins": ["testing-library"],
  "overrides": [
    {
      "files": ["myCypressFiles/**/*.js"],
      "rules": {
        "testing-library/prefer-screen-queries": "off",
        "testing-library/await-async-query": "off"
      }
    }
  ]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

wait - Cypress Documentation
When given a time argument: cy.wait() yields the same subject it was given. It is unsafe to chain further commands that rely on...
Read more >
Explain how commands are chained better in "cy.wait" examples
Based on a conversation with a user who was chaining cy.wait(alias).then(...) I have noticed that our cy.wait page only shows ...
Read more >
8 common mistakes in Cypress (and how to avoid them)
#1: Using explicit waiting ... This first example feels kinda obvious. Whenever you added an explicit wait to your Cypress test, I believe...
Read more >
How to wait for cypress command to finish before moving ...
testCommand() cy.then(() => { console.log('after command runs') }) }) }) ... It's due to the fact that non-cypress commands runs ...
Read more >
Cypress Get Command | Difference between Get and Find ...
How to chain other Cypress commands with "get()" command? ... cy.get('input',{ timeout: 1000 }) // It will wait for 1000ms before timing out....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found