Giter Club home page Giter Club logo

Comments (8)

NicholasBoll avatar NicholasBoll commented on May 20, 2024

I also noticed $el isn't set correctly in the Cypress.log which means debugging won't give you the element returned by the query in the UI even if it shows up in the Yielded of the consoleProps

from cypress-testing-library.

NicholasBoll avatar NicholasBoll commented on May 20, 2024

I also noticed the command does not retry queries even though there is a comment that says it doesn't retry for get* queries...

from cypress-testing-library.

kentcdodds avatar kentcdodds commented on May 20, 2024

These are fantastic recommendations! Would you be willing to make contributions to improve things as you suggest?

from cypress-testing-library.

NicholasBoll avatar NicholasBoll commented on May 20, 2024

Yes! Working on those now

from cypress-testing-library.

NicholasBoll avatar NicholasBoll commented on May 20, 2024

@kentcdodds Question: I read up on all the query types and looked through implementations in this repository: findBy, findByAll, queryBy, queryByAll, getBy, and getByAll.

getBy and getByAll have already been removed from this repo stating it doesn't make as much sense in the context of Cypress.

findBy and findByAll are actually delegating to the queryBy and queryByAll since Cypress handles retries.

queryBy and queryByAll synchronously resolve normally where findBy and findByAll resolve asynchronously. This is somewhat enforced in the code here by only allowing the find types to retry and not letting the query types retry. Does this make sense? All normal Cypress commands always retry. One of the stated usefulness of query resolving synchronously in the docs is to verify non-existence, but Cypress allows testing existence through .should('exist') and non-existence through .should('not.exist').

Does it make still make sense to not retry query* matchers? cy.find* already doesn't match the documentation because it can be modified by .should('not.exist').

I'm debating removing the restriction to not retry cy.query*, but then the functionality is exactly the same as cy.find*

from cypress-testing-library.

alexkrolick avatar alexkrolick commented on May 20, 2024

find queries are the most idiomatic in Cypress, we only have the query ones for legacy reasons at this point I think

from cypress-testing-library.

NicholasBoll avatar NicholasBoll commented on May 20, 2024

@alexkrolick thanks! I agree. In order to have more useful errors, I changed the logic a bit to follow the same codepath as find queries, but with a 1ms duration. This keeps the messages consistent.

As I was thinking about my original issue with the more complex find[All]ByLabelText, I realized the get* query types already have more descriptive error messages. I'll try switching both query* and find* queries to use get* under the hood. Adding a retry-on-error loop will ensure the same retry as before, but with more descriptive error messages straight from @tesing-library/dom

We can see if that seems like the way to go

from cypress-testing-library.

kentcdodds avatar kentcdodds commented on May 20, 2024

🎉 This issue has been resolved in version 5.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from cypress-testing-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.