Skip to content
masterclass Buddy

Cypress · Method

cy.readFile

cy.readFile() reads a file from disk and yields its contents. It can reread the file while chained queries or assertions are not passing, so it works well for downloads and files created during a test.

Last updated

Since
0.17.1

Syntax

cy.readFile(filePath)
cy.readFile(filePath, encoding)
cy.readFile(filePath, options)
cy.readFile(filePath, encoding, options)

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

Subscribe
  • cy.fixture()
  • cy.selectFile()
  • cy.task()
  • cy.writeFile()

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