Bird
0
0

Find the mistake in this Cypress assertion:

medium📝 Debug Q7 of 15
Cypress - Assertions
Find the mistake in this Cypress assertion:
cy.get('input').should('have.value', 123)
AUsing 'have.value' is incorrect here
BValue should be a string, not a number
CMissing 'then' before 'should'
DSelector 'input' is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Check data type of expected value

    Cypress expects the value to be a string when asserting input value.
  2. Step 2: Identify type mismatch

    Here, 123 is a number, which causes the assertion to fail or behave unexpectedly.
  3. Final Answer:

    Value should be a string, not a number -> Option B
  4. Quick Check:

    Input values are strings in assertions [OK]
Quick Trick: Always use strings for input value assertions [OK]
Common Mistakes:
  • Passing numbers instead of strings
  • Assuming Cypress converts types automatically
  • Confusing selector or chaining syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes