How do I get an element in Cypress without it asserting that it is present?
cy.get('.something')
Sometimes my element might not be there and I don't want it to fail the test.
Is there a different command I should be using?
How do I get an element in Cypress without it asserting that it is present?
cy.get('.something')
Sometimes my element might not be there and I don't want it to fail the test.
Is there a different command I should be using?
You can use cy.$$('selector') to synchronously query for an element (jquery).
If you want this to happen after a cypress command, you'll need a .then:
cy.visit('/')
cy.get('element-one').then(() => {
  const $el2 = cy.$$('element-two')
  if ($el2.length) {
    // do this
  } else {
    // do that
  }
})
You might want to check this section of the docs in Cypress https://docs.cypress.io/guides/core-concepts/conditional-testing.html#Element-existence