06 / 07

What is a Fixture in Cypress?

In Cypress, a Fixture is a static file that holds data you can use to simulate network responses or provide input for your tests. Think of it as a 'data double.' Instead of relying on a live database or a real API (which might change or be slow), you store a JSON, image, or text file in the cypress/fixtures folder and tell Cypress to use that data whenever a specific action happens.​

You can use it to:​
  1. 1

    Simulate API responses

  2. 2

    Store reusable test data (e.g. user profiles, login credentials)

  3. 3

    Mock backend data during testing

  4. 4

    It is used keep credentials/config out of code

  5. 5

    Default location is cypress/fixtures/

javascript