Skip to content
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

Bring back queryBy #278

Open
steinybot opened this issue Jun 25, 2024 · 0 comments
Open

Bring back queryBy #278

steinybot opened this issue Jun 25, 2024 · 0 comments

Comments

@steinybot
Copy link

So I know that Cypress have a vendeta out on Conditional Testing but there are cases where it is necessary and worth the risk of flakiness (actually it can reduce flakiness even for a well designed test).

One that I run into a lot is when using visual regression testing such as Percy. Visual regression takes a snapshot so of course it is the programmers responsibility to ensure that the DOM is stable. There is no other choice. The buit in Cypress commands as well as the Testing Library ones makes this pretty easy to do. Once it is stable we can use queries to modify the DOM, such as setting all dates to a known value, and then finally take the snapshot.

Would you consider bringing back the queryBy... APIs?

It is not sufficient to do findBy().should('not.exist') as sometimes we reusable logic that will work whether the elements exist or not.

For the snapshot case I want a single snapshot function which I can call on any page of my app in any state which knows how to replace dates, times, randomly generated emails etc. whether they are present or not. Without this, I have write a custom snapshot function for every single test which is horrible.

The technique used in cypress-if is a pretty good approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant