I have problem when I am using Cypress Testing Library
See original GitHub issueCurrent behavior
TypeError: cy.findByRole is not a function
Desired behavior
I am getting this error even I am using the cypress testing library as in the docs
I have added this line to project cypress/support/commands.js:
import
‘@testing-library/cypress/add-commands’;
And in my test, I use it like this
describe("App", () => {
it("user can fetch stories", () => {
cy.visit("http://localhost:3000/");
cy.findByRole("button", { name: /fetch stories/i }).click();
});
});
then when I run the test I get this error `TypeError: cy.findByRole is not a function
Test code to reproduce
describe("App", () => {
it("user can fetch stories", () => {
cy.visit("http://localhost:3000/");
cy.findByRole("button", { name: /fetch stories/i }).click();
});
});
Cypress Version
9.1.1
Other
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Cypress Testing Library
Examples Cypress Testing Library supports both jQuery elements and DOM nodes. This is necessary because Cypress uses jQuery elements, while ...
Read more >Best Practices - Cypress Documentation
We use Testing Library internally, and our philosophy aligns closely with Testing Library's ethos and approach to writing tests. We strongly endorse their...
Read more >Using testing-library findby* queries with @badeball/cypress ...
I have a react app that I'm trying to test with Cypress using the badeball/cypress-cucumber-preprocessor and testing-library but I'm getting ...
Read more >@testing-library/cypress - npm
The problem. You want to use DOM Testing Library methods in your Cypress tests. This solution. This allows you to use all the...
Read more >Which query to use? - Mattermost Developers
With that, which query should I use when writing Cypress tests? ... Do you still have problems knowing how to use Testing Library...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I fix it, by adding an index.js file in cypress/support/
@np185092 I fixed the problem by adding the "import ‘@testing-library/cypress/add-commands’ line to the cypress/support/command.ts " file