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 153 forks source link

Add autocomplete support for the should(chainer, ...) variants #131

Closed tormodhau closed 4 years ago

tormodhau commented 4 years ago

Environment:

Relevant code or config:

  // ts.config
  "compilerOptions": {
    "strict": true,
    "baseUrl": "../node_modules",
    "target": "es5",
    "lib": ["es5", "dom"],
    "types": ["cypress", "@types/testing-library__cypress"],
    "noEmit": false
  },
// support/index.ts
import "@testing-library/cypress/add-commands";

What you did:

cy.findAllByText('"Some text').should('have.length', 2);

What happened:

image

You get a warning and no autocompletion. The code runs just fine.

Problem description:

When using the cy.get().should()-syntax in Cypress, you get autocompletion for all the "chainer" variants (as in should("chainer")). Using e.g cy.findByText().should() from CTL will not only give you a linter warning, but also no autocompletion.

Suggested solution:

If there is an existing solution to this issue, please add it to the readme. Alternatively: perhaps it would be possible to add the Typescript definitions for each should-variant as they have done for the original cy.get().should()-variants?

kentcdodds commented 4 years ago

I think this is resolved in the latest version.