Bird
0
0

Given the code:

hard📝 Application Q9 of 15
Cypress - Assertions
Given the code:
const user = { name: 'Alice', age: 30, active: true };
expect(user).to.have.property('age').that.is.a('number').and.is.above(18);

What does this assertion check?
AUser object is exactly equal to the given object
BUser has an age property equal to 18
CUser has an active property that is true
DUser has an age property that is a number greater than 18
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the chained assertions on user object

    The assertion checks that user has a property age, which is a number and greater than 18.
  2. Step 2: Eliminate incorrect interpretations

    It does not check equality to 18, active property, or full object equality.
  3. Final Answer:

    User has an age property that is a number greater than 18 -> Option D
  4. Quick Check:

    Property check with type and value conditions [OK]
Quick Trick: Chain property, type, and value checks for detailed assertions [OK]
Common Mistakes:
  • Confusing property with full object equality
  • Ignoring chained type checks
  • Misreading comparison operators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes