Skip to content
masterclass Buddy

Cypress · Method

cy.writeFile

cy.writeFile() writes text or structured data to a file under the Cypress project root. It creates missing paths, overwrites files by default, and can use encodings or file options.

Last updated

Since
1.0.0

Syntax

cy.writeFile(filePath, contents)
cy.writeFile(filePath, contents, encoding)
cy.writeFile(filePath, contents, options)
cy.writeFile(filePath, contents, encoding, options)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • cy.readFile()
  • cy.fixture()
  • cy.request()

Source: cy.writeFile() | Cypress API Documentation. Checked 2026-11-03.