Bird
0
0

How can you assert that the JSON file config.json does NOT contain the key debug?

hard📝 Application Q9 of 15
Cypress - File Operations
How can you assert that the JSON file config.json does NOT contain the key debug?
Acy.readFile('config.json').should('not.contain', 'debug')
Bcy.readFile('config.json').should('not.include', {debug: true})
Ccy.readFile('config.json').should('not.have.property', 'debug')
Dcy.readFile('config.json').should('not.exist', 'debug')
Step-by-Step Solution
Solution:
  1. Step 1: Identify assertion to check absence of a property

    not.have.property asserts the object does not have the specified key.
  2. Step 2: Evaluate other options

    Options A and B check for key-value or string presence, which may not be precise. cy.readFile('config.json').should('not.exist', 'debug') is invalid syntax.
  3. Final Answer:

    cy.readFile('config.json').should('not.have.property', 'debug') -> Option C
  4. Quick Check:

    Use not.have.property to assert missing keys [OK]
Quick Trick: Use not.have.property to check key absence [OK]
Common Mistakes:
  • Using not.include which checks values too
  • Using not.exist which is invalid here
  • Checking string presence instead of property

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes