Bird
0
0

What is wrong with this code?

medium📝 Debug Q7 of 15
Cypress - File Operations
What is wrong with this code?
cy.writeFile('results.json', {score: 100, passed: true}, {encoding: 'utf-8', append: true})
AFile name must end with .txt
BEncoding must be 'utf8' without dash
CData must be a string, not an object
DThe append option is not supported by cy.writeFile
Step-by-Step Solution
Solution:
  1. Step 1: Review cy.writeFile options

    cy.writeFile does not support an append option to add content.
  2. Step 2: Check other options validity

    Encoding 'utf-8' is valid, data can be object, file extension is flexible.
  3. Final Answer:

    The append option is not supported by cy.writeFile -> Option D
  4. Quick Check:

    No append option in cy.writeFile [OK]
Quick Trick: cy.writeFile overwrites; no append option exists [OK]
Common Mistakes:
  • Trying to append with cy.writeFile
  • Misnaming encoding format
  • Assuming file extension restrictions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes