Bird
0
0

What is wrong with this Cypress assertion?

medium📝 Debug Q7 of 15
Cypress - Assertions
What is wrong with this Cypress assertion?
cy.get('input').should('have.value', '123').and('be.disabled').should('be.enabled')
AMissing semicolon after each assertion
BConflicting assertions: element cannot be both disabled and enabled
CIncorrect chaining order of should() and and()
DNo error, chaining is valid
Step-by-Step Solution
Solution:
  1. Step 1: Review the chained assertions

    The code asserts the element is disabled and then enabled, which is logically impossible simultaneously.
  2. Step 2: Understand assertion conflicts

    Assertions must be consistent; conflicting states cause test failure.
  3. Final Answer:

    Conflicting assertions: element cannot be both disabled and enabled -> Option B
  4. Quick Check:

    Conflicting assertions cause test failure [OK]
Quick Trick: Avoid contradictory assertions in chained should() calls [OK]
Common Mistakes:
  • Chaining contradictory assertions
  • Ignoring logical consistency of element states
  • Assuming chaining order fixes conflicts

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes