Closed jamesarosen closed 9 months ago
I think this is expected behavior given the README:
query* queries are not supported. You should use the should('not.exist') assertion instead to check for the absence of an element.
get queries are not supported. find queries do not use the Promise API of DOM Testing Library, but instead forward to the get queries and use Cypress' built-in retryability using error messages from get APIs to forward as error messages if a query fails.
I think this is an issue with the Cypress Testing Library docs.
Lost some time to realising this as well, opened pull request for that: https://github.com/testing-library/testing-library-docs/pull/1344
Thanks to @vadimshvetsov this is now properly documented. I'm closing this one as it was a documentation issue, these queries aren't meant to be supported.
The issue template says that questions about query APIs should go to https://github.com/kentcdodds/dom-testing-library, but these methods do exist there: https://github.com/testing-library/dom-testing-library/blob/0ce0c7054dfa64d1cd65053790246aed151bda9d/types/queries.d.ts#L297-L302
The Cypress Testing Library docs say
Those same docs reference "all library definitions". That file includes only
findBy…
andfindAllBy…
methods.cy.queryAllByTestId
, for example, doesn't exist.cypress-testing-library
version: 8.0.3node
version: v16.17.1npm
(oryarn
) version: 8.15.0Why I care
I want to look for
[data-testid="foo"]
-- which may or may not exist -- then make a decision based on what I get back. I want to wait for the standard timeout to make sure the element doesn't exist, so I don't want to just usedocument.querySelector
.