testing-library / cypress-testing-library

🐅 Simple and complete custom Cypress commands and utilities that encourage good testing practices.
http://npm.im/@testing-library/cypress
MIT License
1.8k stars 152 forks source link

My linter configuration throw errors because commands from cypress-testing-library seem to be not working properly. #229

Open NicoMoli opened 1 year ago

NicoMoli commented 1 year ago

Relevant code or config

Print screen of my cypress/support/command.js

Captura de Pantalla 2022-08-30 a la(s) 09 48 58

What you did:

I am trying to use Cypress with cypress-testing-library (the entire project is using typescript).

What happened:

When I am trying to use, for example findByRole query I obtain this linter error.

Captura de Pantalla 2022-08-30 a la(s) 09 50 37

Problem description:

The cypress components tests are able to run successfully but my linter config is no very happy about it.

dimas-cyriaco commented 1 year ago

I'm having the same problem.

mpaternostro commented 1 year ago

Was having the same problem after following setup from cypress-testing-library docs, solved it by adding a reference comment like so:

/// <reference types="cypress" />
/// <reference types="@testing-library/cypress" />
/// add this at the top of your test files 👆

Hope it solves your problem!

NicoMoli commented 1 year ago

Thanks Marcelo. I am gonna to try your solution.

srflp commented 1 year ago

If you're using TypeScript, just add @testing-library/cypress to your tsconfig.json under compilerOptions.types like this:

{
  "compilerOptions": {
    ...
    "types": [..., "@testing-library/cypress"]
  }
}