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

CTL not working in custom commands #218

Closed lmazurek closed 2 years ago

lmazurek commented 2 years ago

Hello everyone :)

I imported cypress-testing-library into support/index.js:

import '@testing-library/cypress/add-commands';

CTL Commands work in the tests, but they do not work when I try to use them in my custom commands, e.g.:

Cypress.Commands.add('getAutosuggestByLabel', label => {
  return cy.getByLabelText(label);
})

When using this command I get:

TypeError cy.getByLabelText is not a function

Is that normal, or did I do something wrong?

PS. Yes the above command is silly, but it's just an example ;)

lmazurek commented 2 years ago

darn, I've just noticed I used get instead of find.... so sorry :)