Complete the code to write the string 'Hello World' to a file named 'greeting.txt'.
cy.[1]('greeting.txt', 'Hello World')
The cy.writeFile command writes data to a file. Here, it writes 'Hello World' to 'greeting.txt'.
Complete the code to write an object { name: 'Alice' } to 'user.json' as JSON.
cy.[1]('user.json', { name: 'Alice' })
cy.writeFile can write objects as JSON to files. Here, it writes the object to 'user.json'.
Fix the error in the code to correctly write 'Test data' to 'data.txt'.
cy.writeFile('data.txt', [1])
The data to write must be a string or object. It must be quoted as a string literal. Without quotes, it causes an error.
Fill both blanks to write an array ['apple', 'banana'] to 'fruits.json' as JSON.
cy.[1]('fruits.json', [2])
cy.writeFile writes data to files. The data here is an array, so it must be passed as is (not as a string).
Fill all three blanks to write a JSON object with uppercase keys to 'config.json'.
const config = { [1]: 'value1', [2]: 'value2' };
cy.[3]('config.json', config);The object keys are uppercase strings. The command to write the file is writeFile.