-
Notifications
You must be signed in to change notification settings - Fork 154
[solved] I get an error message if I don't prepend calls to findBy... with a get('body') call #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Just posted this for anyone encoutering this. Turns out cypress-testing-library no longer supports chaining commands, so you have to write something like: cy.visit('/page');
cy.findByText(/okay/i).click();
cy.findByText(/another button/i).click() |
This sounds like a bug? |
Hmmm... cc @NicholasBoll? |
Oh sorry, it’s just a new API - you’re not supposed to chain stuff any more. Perhaps we could implement a better error message? |
@dutzi It isn't true that Cypress Testing Library no longer supports chaining. It now supports scoping. All Cypress Testing Library queries are called Dual Commands: https://docs.cypress.io/api/cypress-api/custom-commands.html#Dual-Commands. Previously they were Parent Commands: https://docs.cypress.io/api/cypress-api/custom-commands.html#Parent-Commands The difference is if a query starts a chain, it will assume a global context (find from the root of the document). If you have a previous subject, it will start there. Before it wasn't possible to scope any I like to think of a "chain" like I think of a sentence. There is a primary subject and something acting on that subject - either an action (like More info on subject management: https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Subject-Management Change was here: #130 |
Very well said. Thanks @NicholasBoll 👍👍👏 |
cypress-testing-library
version: ^6.0.0node
version: v10.21.0npm
(oryarn
) version: 1.22.4 (yarn)Relevant code or config
What you did:
I visit a page and call
findByText
What happened:
I get the following error message:
If I call
get('body')
before callingfindByText
it works:The text was updated successfully, but these errors were encountered: