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
Implicit should 'exist' assertion is not being applied on cy.get() when other assertion. #205
Comments
This is because internally Cypress applies a default assertion Since you added additional assertions the implicit Cypress needs to be updated to always apply the default |
I like to have Currently for a non-existing selection my example returns |
I'm getting some weird behavior with this, when trying this assertion: cy.visit('/')
.get('#signup').should('not.exist') the assertion fails and prints: it look like a bug as the |
@udisun It seems unlikely that is the entirety of your code. Can you put together a reproducible repo? |
@brian-mann i've created a very small repo with the example of |
@brian-mann did you check my example project, do you have an explanation why the command isn't working? thanks |
@udisun I looked at your repo and you did not provide a proper query selector to the https://github.com/udisun/cypress-first-steps/blob/master/cypress/integration/app_spec.js#L13 There is no element called |
This comment has been minimized.
This comment has been minimized.
I think this is large enough issue to warrant doc changes, particularly in https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Default-Assertions and https://docs.cypress.io/api/commands/should.html#Syntax. Should I open a PR? |
Hey @dwelle, yes you can open an issue and/or PR from our documentation repo. https://github.com/cypress-io/cypress-documentation |
Hi, this is due to a bug fixed in this PR #3268 Edit: updated with correct PR |
An example on why this current implementation is a problem. Example 1If you have an element that did exist and then sets the elements visibility to cy.get(el).should(not.be.visible)
cy.get(el).should(be.visible) |
Another use case from #6958 - notice I'm not even visiting a website and this passes because the checkbox doesn't event exist. it('testing', () => {
cy.get('input').should('not.be.checked')
}) |
@jennifer-shehane hi, is there any progress on that issue? |
We're looking into the details of this issue again, to see if we can get this into one of our future breaking releases. |
The code for this is done in cypress-io/cypress#9239, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Using
cy.get()
on an element should implicitly assert existence of the element. But in my examples below, you can see that I have no elementfoobarbaz
, the Command Log correctly logs0
elements found, yet my explicitly written assertions (not.be.visible
andnot.have.class
) chained off of the gotten element pass.cy.get()
should always implicitly assert existence unless there is an explicit assertion down the chain on that element asserting that it shouldnot.exist
.Example Test Code
Example Command Log

The text was updated successfully, but these errors were encountered: