Bird
0
0

Given data.json contains {"user": {"id": 5, "active": true}}, what will this test assert?

medium📝 Predict Output Q4 of 15
Cypress - File Operations
Given data.json contains {"user": {"id": 5, "active": true}}, what will this test assert?
cy.readFile('data.json').its('user.active').should('be.true')
AThe test will fail because user.active is false
BThe test will pass because user.active is true
CThe test will fail due to syntax error
DThe test will pass but does not check user.active
Step-by-Step Solution
Solution:
  1. Step 1: Understand the file content and property access

    The file has user.active set to true, and its('user.active') accesses that property.
  2. Step 2: Analyze the assertion

    should('be.true') asserts the value is true, which matches the file content.
  3. Final Answer:

    The test will pass because user.active is true -> Option B
  4. Quick Check:

    Property access and boolean assertion = pass [OK]
Quick Trick: Use its() to access nested properties easily [OK]
Common Mistakes:
  • Assuming user.active is false
  • Confusing should('be.true') with string check
  • Thinking its() causes syntax error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes