Bird
0
0

You want to save multiple test results to the same file without overwriting previous data. Which approach using cy.writeFile() is correct?

hard📝 Application Q8 of 15
Cypress - File Operations
You want to save multiple test results to the same file without overwriting previous data. Which approach using cy.writeFile() is correct?
AUse cy.writeFile with append: true option
BUse cy.writeFile with encoding: 'append'
CCall cy.writeFile multiple times; it appends automatically
DRead the file, append new data in memory, then write back with cy.writeFile
Step-by-Step Solution
Solution:
  1. Step 1: Understand cy.writeFile behavior

    It overwrites files; no append option exists.
  2. Step 2: Find correct way to append data

    Read existing file content, add new data in code, then write full content back.
  3. Final Answer:

    Read the file, append new data in memory, then write back with cy.writeFile -> Option D
  4. Quick Check:

    Append by reading and rewriting file [OK]
Quick Trick: Append by reading file, modifying data, then writing [OK]
Common Mistakes:
  • Expecting append option in cy.writeFile
  • Calling writeFile multiple times expecting append
  • Using invalid encoding values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes