Execution Trace Quiz - 3 Questions
Test your understanding
What does cy.writeFile do in this test?
cy.writeFile() in Cypress testing?cy.writeFile() is used to save or write data into a file during Cypress tests.cy.readFile() reads data, but cy.writeFile() writes data. Deleting or opening files is not its purpose.cy.writeFile()?cy.writeFile() takes the file path as first argument and the content as second argument, which can be a string.cy.writeFile('data.json', { name: 'Alice', age: 30 })
cy.readFile('data.json').then((content) => {
console.log(content.age)
})content.age, which is 30.cy.writeFile('user.json', '{"name": "Bob", "age": 25}')cy.writeFile(). Which code snippet correctly appends the text without overwriting the file?{ flag: 'a+' } to append instead of overwrite.Pass the test and this pattern moves unknown