{
  "doc": {
    "id": "api/commands/fixture",
    "title": "fixture | Cypress Documentation",
    "description": "Load a fixed set of data located in a file in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/fixture.md",
    "version": "24a73f8a97175663aaffd3b016289fb2a523a4ea",
    "updated_at": "2026-05-14T20:17:33.301Z",
    "headings": [
      {
        "id": "api/commands/fixture#fixture",
        "text": "fixture",
        "level": 1
      },
      {
        "id": "api/commands/fixture#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/fixture#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/fixture#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/fixture#yields-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "level": 3
      },
      {
        "id": "api/commands/fixture#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/fixture#json",
        "text": "JSON",
        "level": 3
      },
      {
        "id": "api/commands/fixture#load-a-users-json-fixture",
        "text": "Load a users.json fixture",
        "level": 4
      },
      {
        "id": "api/commands/fixture#omit-the-fixture-files-extension",
        "text": "Omit the fixture file's extension",
        "level": 4
      },
      {
        "id": "api/commands/fixture#use-import-statement",
        "text": "Use import statement",
        "level": 4
      },
      {
        "id": "api/commands/fixture#images",
        "text": "Images",
        "level": 3
      },
      {
        "id": "api/commands/fixture#image-fixtures-are-sent-as-base64-by-default",
        "text": "Image fixtures are sent as base64 by default",
        "level": 4
      },
      {
        "id": "api/commands/fixture#change-encoding-of-image-fixture",
        "text": "Change encoding of Image fixture",
        "level": 4
      },
      {
        "id": "api/commands/fixture#playing-mp3-file",
        "text": "Playing MP3 file",
        "level": 3
      },
      {
        "id": "api/commands/fixture#accessing-fixture-data",
        "text": "Accessing Fixture Data",
        "level": 3
      },
      {
        "id": "api/commands/fixture#using-then-to-access-fixture-data",
        "text": "Using .then() to access fixture data",
        "level": 4
      },
      {
        "id": "api/commands/fixture#using-fixtures-to-bootstrap-data",
        "text": "Using fixtures to bootstrap data",
        "level": 4
      },
      {
        "id": "api/commands/fixture#modifying-fixture-data-before-using-it",
        "text": "Modifying fixture data before using it",
        "level": 4
      },
      {
        "id": "api/commands/fixture#notes",
        "text": "Notes",
        "level": 2
      },
      {
        "id": "api/commands/fixture#shortcuts",
        "text": "Shortcuts",
        "level": 3
      },
      {
        "id": "api/commands/fixture#using-the-fixture-staticresponse-property",
        "text": "Using the fixture StaticResponse property",
        "level": 4
      },
      {
        "id": "api/commands/fixture#validation",
        "text": "Validation",
        "level": 3
      },
      {
        "id": "api/commands/fixture#automated-file-validation",
        "text": "Automated File Validation",
        "level": 4
      },
      {
        "id": "api/commands/fixture#encoding",
        "text": "Encoding",
        "level": 3
      },
      {
        "id": "api/commands/fixture#default-encoding",
        "text": "Default Encoding",
        "level": 4
      },
      {
        "id": "api/commands/fixture#this-context",
        "text": "this context",
        "level": 3
      },
      {
        "id": "api/commands/fixture#loaded-just-once",
        "text": "Loaded just once",
        "level": 3
      },
      {
        "id": "api/commands/fixture#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/fixture#requirements-learn-about-chaining-commands",
        "text": "Requirements Learn about chaining commands",
        "level": 3
      },
      {
        "id": "api/commands/fixture#assertions-learn-about-assertions",
        "text": "Assertions Learn about assertions",
        "level": 3
      },
      {
        "id": "api/commands/fixture#timeouts-learn-about-timeouts",
        "text": "Timeouts Learn about timeouts",
        "level": 3
      },
      {
        "id": "api/commands/fixture#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/fixture#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/fixture#syntax",
      "doc_id": "api/commands/fixture",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\ncy.fixture(filePath)cy.fixture(filePath, encoding)cy.fixture(filePath, options)cy.fixture(filePath, encoding, options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.fixture('users').as('usersJson') // load data from users.jsoncy.fixture('logo.png').then((logo) => {  // load data from logo.png})\n```\n\n### Arguments\n\n**filePath _(String)_**\n\nA path to a file within the [`fixturesFolder`](/llm/markdown/app/references/configuration.md#Folders--Files) , which defaults to `cypress/fixtures`.\n\nYou can nest fixtures within folders and reference them by defining the path from the fixturesFolder:\n\n```\ncy.fixture('users/admin.json') // Get data from {fixturesFolder}/users/admin.json\n```\n\n**encoding _(String)_**\n\nThe encoding to be used when reading the file. The following encodings are supported:\n\n*   `'ascii'`\n*   `'base64'`\n*   `'binary'`\n*   `'hex'`\n*   `'latin1'`\n*   `'utf8'`\n*   `'utf-8'`\n*   `'ucs2'`\n*   `'ucs-2'`\n*   `'utf16le'`\n*   `'utf-16le'`\n*   `null`\n\nUsing `null` explicitly will return the fixture as a [`Cypress.Buffer`](/llm/markdown/api/utilities/buffer.md) instance, regardless of file extension.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.fixture()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `timeout` | [`responseTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.fixture()` to resolve before [timing out](#Timeouts) |\n\n### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n*   `cy.fixture()` yields the contents of the file. Formatting is determined by its file extension.\n*   The yielded subject is **not** updated if the contents change on disk.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 269
    },
    {
      "id": "api/commands/fixture#arguments",
      "doc_id": "api/commands/fixture",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**filePath _(String)_**\n\nA path to a file within the [`fixturesFolder`](/llm/markdown/app/references/configuration.md#Folders--Files) , which defaults to `cypress/fixtures`.\n\nYou can nest fixtures within folders and reference them by defining the path from the fixturesFolder:\n\n```\ncy.fixture('users/admin.json') // Get data from {fixturesFolder}/users/admin.json\n```\n\n**encoding _(String)_**\n\nThe encoding to be used when reading the file. The following encodings are supported:\n\n*   `'ascii'`\n*   `'base64'`\n*   `'binary'`\n*   `'hex'`\n*   `'latin1'`\n*   `'utf8'`\n*   `'utf-8'`\n*   `'ucs2'`\n*   `'ucs-2'`\n*   `'utf16le'`\n*   `'utf-16le'`\n*   `null`\n\nUsing `null` explicitly will return the fixture as a [`Cypress.Buffer`](/llm/markdown/api/utilities/buffer.md) instance, regardless of file extension.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.fixture()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `timeout` | [`responseTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.fixture()` to resolve before [timing out](#Timeouts) |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 187
    },
    {
      "id": "api/commands/fixture#yields-learn-about-subject-management",
      "doc_id": "api/commands/fixture",
      "heading": "Yields Learn about subject management",
      "heading_level": 3,
      "content_markdown": "### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n*   `cy.fixture()` yields the contents of the file. Formatting is determined by its file extension.\n*   The yielded subject is **not** updated if the contents change on disk.\n",
      "section": "api",
      "anchors": [
        "yields-learn-about-subject-management"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 45
    },
    {
      "id": "api/commands/fixture#examples",
      "doc_id": "api/commands/fixture",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### JSON\n\n#### Load a `users.json` fixture\n\n```\ncy.fixture('users.json').as('usersData')\n```\n\n#### Omit the fixture file's extension\n\nWhen no extension is passed to `cy.fixture()`, Cypress will search for files with the specified name within the [`fixturesFolder`](/llm/markdown/app/references/configuration.md#Folders--Files) (which defaults to `cypress/fixtures`) and resolve the first one.\n\n```\ncy.fixture('admin').as('adminJSON')\n```\n\nThe example above would resolve in the following order:\n\n1.  `cypress/fixtures/admin.json`\n2.  `cypress/fixtures/admin.js`\n3.  `cypress/fixtures/admin.coffee`\n4.  `cypress/fixtures/admin.html`\n5.  `cypress/fixtures/admin.txt`\n6.  `cypress/fixtures/admin.csv`\n7.  `cypress/fixtures/admin.png`\n8.  `cypress/fixtures/admin.jpg`\n9.  `cypress/fixtures/admin.jpeg`\n10.  `cypress/fixtures/admin.gif`\n11.  `cypress/fixtures/admin.tif`\n12.  `cypress/fixtures/admin.tiff`\n13.  `cypress/fixtures/admin.zip`\n\n#### Use import statement\n\nIf you are loading a JSON fixture, you can simply use the `import` statement and let the bundler load it:\n\n```\n// cypress/e2e/spec.cy.jsimport user from '../fixtures/user.json'it('loads the same object', () => {  cy.fixture('user').then((userFixture) => {    expect(user, 'the same data').to.deep.equal(userFixture)  })})\n```\n\n### Images\n\n#### Image fixtures are sent as `base64` by default\n\n```\ncy.fixture('images/logo.png').then((logo) => {  // logo will be encoded as base64  // and should look something like this:  // aIJKnwxydrB10NVWqhlmmC+ZiWs7otHotSAAAOw==...})\n```\n\n#### Change encoding of Image fixture\n\n```\ncy.fixture('images/logo.png', null).then((logo) => {  // logo will be read as a buffer  // and should look something like this:  // Buffer([0, 0, ...])  expect(Cypress.Buffer.isBuffer(logo)).to.be.true})\n```\n\n### Playing MP3 file\n\n```\ncy.fixture('audio/sound.mp3', 'base64').then((mp3) => {  const uri = 'data:audio/mp3;base64,' + mp3  const audio = new Audio(uri)  audio.play()})\n```\n\n### Accessing Fixture Data\n\n#### Using `.then()` to access fixture data\n\n```\ncy.fixture('users').then((json) => {  cy.intercept('GET', '/users/**', json)})\n```\n\n#### Using fixtures to bootstrap data\n\n[Check out our example recipe using `cy.fixture()` to bootstrap data for our application.](/llm/markdown/app/references/recipes.md#Server-Communication)\n\n#### Modifying fixture data before using it\n\nYou can modify fixture data directly before visiting a URL or mounting a component that makes a network request to that URL.\n\n*   End-to-End Test\n*   Component Test\n\n```\ncy.fixture('user').then((user) => {  user.firstName = 'Jane'  cy.intercept('GET', '/users/1', user).as('getUser')})cy.visit('/users')cy.wait('@getUser').then(({ request }) => {  expect(request.body.firstName).to.eq('Jane')})\n```\n\n```\ncy.fixture('user').then((user) => {  user.firstName = 'Jane'  cy.intercept('GET', '/users/1', user).as('getUser')})cy.mount(<Users />)cy.wait('@getUser').then(({ request }) => {  expect(request.body.firstName).to.eq('Jane')})\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 428
    },
    {
      "id": "api/commands/fixture#json",
      "doc_id": "api/commands/fixture",
      "heading": "JSON",
      "heading_level": 3,
      "content_markdown": "### JSON\n\n#### Load a `users.json` fixture\n\n```\ncy.fixture('users.json').as('usersData')\n```\n\n#### Omit the fixture file's extension\n\nWhen no extension is passed to `cy.fixture()`, Cypress will search for files with the specified name within the [`fixturesFolder`](/llm/markdown/app/references/configuration.md#Folders--Files) (which defaults to `cypress/fixtures`) and resolve the first one.\n\n```\ncy.fixture('admin').as('adminJSON')\n```\n\nThe example above would resolve in the following order:\n\n1.  `cypress/fixtures/admin.json`\n2.  `cypress/fixtures/admin.js`\n3.  `cypress/fixtures/admin.coffee`\n4.  `cypress/fixtures/admin.html`\n5.  `cypress/fixtures/admin.txt`\n6.  `cypress/fixtures/admin.csv`\n7.  `cypress/fixtures/admin.png`\n8.  `cypress/fixtures/admin.jpg`\n9.  `cypress/fixtures/admin.jpeg`\n10.  `cypress/fixtures/admin.gif`\n11.  `cypress/fixtures/admin.tif`\n12.  `cypress/fixtures/admin.tiff`\n13.  `cypress/fixtures/admin.zip`\n\n#### Use import statement\n\nIf you are loading a JSON fixture, you can simply use the `import` statement and let the bundler load it:\n\n```\n// cypress/e2e/spec.cy.jsimport user from '../fixtures/user.json'it('loads the same object', () => {  cy.fixture('user').then((userFixture) => {    expect(user, 'the same data').to.deep.equal(userFixture)  })})\n```\n",
      "section": "api",
      "anchors": [
        "json"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 169
    },
    {
      "id": "api/commands/fixture#omit-the-fixture-files-extension",
      "doc_id": "api/commands/fixture",
      "heading": "Omit the fixture file's extension",
      "heading_level": 4,
      "content_markdown": "#### Omit the fixture file's extension\n\nWhen no extension is passed to `cy.fixture()`, Cypress will search for files with the specified name within the [`fixturesFolder`](/llm/markdown/app/references/configuration.md#Folders--Files) (which defaults to `cypress/fixtures`) and resolve the first one.\n\n```\ncy.fixture('admin').as('adminJSON')\n```\n\nThe example above would resolve in the following order:\n\n1.  `cypress/fixtures/admin.json`\n2.  `cypress/fixtures/admin.js`\n3.  `cypress/fixtures/admin.coffee`\n4.  `cypress/fixtures/admin.html`\n5.  `cypress/fixtures/admin.txt`\n6.  `cypress/fixtures/admin.csv`\n7.  `cypress/fixtures/admin.png`\n8.  `cypress/fixtures/admin.jpg`\n9.  `cypress/fixtures/admin.jpeg`\n10.  `cypress/fixtures/admin.gif`\n11.  `cypress/fixtures/admin.tif`\n12.  `cypress/fixtures/admin.tiff`\n13.  `cypress/fixtures/admin.zip`\n",
      "section": "api",
      "anchors": [
        "omit-the-fixture-files-extension"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 96
    },
    {
      "id": "api/commands/fixture#use-import-statement",
      "doc_id": "api/commands/fixture",
      "heading": "Use import statement",
      "heading_level": 4,
      "content_markdown": "#### Use import statement\n\nIf you are loading a JSON fixture, you can simply use the `import` statement and let the bundler load it:\n\n```\n// cypress/e2e/spec.cy.jsimport user from '../fixtures/user.json'it('loads the same object', () => {  cy.fixture('user').then((userFixture) => {    expect(user, 'the same data').to.deep.equal(userFixture)  })})\n```\n",
      "section": "api",
      "anchors": [
        "use-import-statement"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 60
    },
    {
      "id": "api/commands/fixture#images",
      "doc_id": "api/commands/fixture",
      "heading": "Images",
      "heading_level": 3,
      "content_markdown": "### Images\n\n#### Image fixtures are sent as `base64` by default\n\n```\ncy.fixture('images/logo.png').then((logo) => {  // logo will be encoded as base64  // and should look something like this:  // aIJKnwxydrB10NVWqhlmmC+ZiWs7otHotSAAAOw==...})\n```\n\n#### Change encoding of Image fixture\n\n```\ncy.fixture('images/logo.png', null).then((logo) => {  // logo will be read as a buffer  // and should look something like this:  // Buffer([0, 0, ...])  expect(Cypress.Buffer.isBuffer(logo)).to.be.true})\n```\n",
      "section": "api",
      "anchors": [
        "images"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 85
    },
    {
      "id": "api/commands/fixture#image-fixtures-are-sent-as-base64-by-default",
      "doc_id": "api/commands/fixture",
      "heading": "Image fixtures are sent as base64 by default",
      "heading_level": 4,
      "content_markdown": "#### Image fixtures are sent as `base64` by default\n\n```\ncy.fixture('images/logo.png').then((logo) => {  // logo will be encoded as base64  // and should look something like this:  // aIJKnwxydrB10NVWqhlmmC+ZiWs7otHotSAAAOw==...})\n```\n",
      "section": "api",
      "anchors": [
        "image-fixtures-are-sent-as-base64-by-default"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 40
    },
    {
      "id": "api/commands/fixture#change-encoding-of-image-fixture",
      "doc_id": "api/commands/fixture",
      "heading": "Change encoding of Image fixture",
      "heading_level": 4,
      "content_markdown": "#### Change encoding of Image fixture\n\n```\ncy.fixture('images/logo.png', null).then((logo) => {  // logo will be read as a buffer  // and should look something like this:  // Buffer([0, 0, ...])  expect(Cypress.Buffer.isBuffer(logo)).to.be.true})\n```\n",
      "section": "api",
      "anchors": [
        "change-encoding-of-image-fixture"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 43
    },
    {
      "id": "api/commands/fixture#accessing-fixture-data",
      "doc_id": "api/commands/fixture",
      "heading": "Accessing Fixture Data",
      "heading_level": 3,
      "content_markdown": "### Accessing Fixture Data\n\n#### Using `.then()` to access fixture data\n\n```\ncy.fixture('users').then((json) => {  cy.intercept('GET', '/users/**', json)})\n```\n\n#### Using fixtures to bootstrap data\n\n[Check out our example recipe using `cy.fixture()` to bootstrap data for our application.](/llm/markdown/app/references/recipes.md#Server-Communication)\n\n#### Modifying fixture data before using it\n\nYou can modify fixture data directly before visiting a URL or mounting a component that makes a network request to that URL.\n\n*   End-to-End Test\n*   Component Test\n\n```\ncy.fixture('user').then((user) => {  user.firstName = 'Jane'  cy.intercept('GET', '/users/1', user).as('getUser')})cy.visit('/users')cy.wait('@getUser').then(({ request }) => {  expect(request.body.firstName).to.eq('Jane')})\n```\n\n```\ncy.fixture('user').then((user) => {  user.firstName = 'Jane'  cy.intercept('GET', '/users/1', user).as('getUser')})cy.mount(<Users />)cy.wait('@getUser').then(({ request }) => {  expect(request.body.firstName).to.eq('Jane')})\n```\n",
      "section": "api",
      "anchors": [
        "accessing-fixture-data"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 141
    },
    {
      "id": "api/commands/fixture#modifying-fixture-data-before-using-it",
      "doc_id": "api/commands/fixture",
      "heading": "Modifying fixture data before using it",
      "heading_level": 4,
      "content_markdown": "#### Modifying fixture data before using it\n\nYou can modify fixture data directly before visiting a URL or mounting a component that makes a network request to that URL.\n\n*   End-to-End Test\n*   Component Test\n\n```\ncy.fixture('user').then((user) => {  user.firstName = 'Jane'  cy.intercept('GET', '/users/1', user).as('getUser')})cy.visit('/users')cy.wait('@getUser').then(({ request }) => {  expect(request.body.firstName).to.eq('Jane')})\n```\n\n```\ncy.fixture('user').then((user) => {  user.firstName = 'Jane'  cy.intercept('GET', '/users/1', user).as('getUser')})cy.mount(<Users />)cy.wait('@getUser').then(({ request }) => {  expect(request.body.firstName).to.eq('Jane')})\n```\n",
      "section": "api",
      "anchors": [
        "modifying-fixture-data-before-using-it"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 91
    },
    {
      "id": "api/commands/fixture#notes",
      "doc_id": "api/commands/fixture",
      "heading": "Notes",
      "heading_level": 2,
      "content_markdown": "## Notes\n\n### Shortcuts\n\n#### Using the `fixture` `StaticResponse` property\n\nFixtures can also be referenced directly without using the `.fixture()` command by using the special property `fixture` on the [`cy.intercept()`](/llm/markdown/api/commands/intercept.md) `StaticResponse` object.\n\n```\ncy.intercept('GET', '/users/**', { fixture: 'users' })\n```\n\n### Validation\n\n#### Automated File Validation\n\nCypress automatically validates your fixtures. If your `.json`, `.js`, or `.coffee` files contain syntax errors, they will be shown in the Command Log.\n\n### Encoding\n\n#### Default Encoding\n\nCypress automatically determines the encoding for the following file types:\n\n*   `.json`\n*   `.js`\n*   `.coffee`\n*   `.html`\n*   `.txt`\n*   `.csv`\n*   `.png`\n*   `.jpg`\n*   `.jpeg`\n*   `.gif`\n*   `.tif`\n*   `.tiff`\n*   `.zip`\n\nFor other types of files, they will be read as `utf8` by default, unless specified in the second argument of `cy.fixture()`. You can specify `null` as the encoding in order to read the file as a [`Cypress.Buffer`](/llm/markdown/api/utilities/buffer.md) instance instead.\n\n### `this` context\n\nIf you store and access the fixture data using `this` test context object, make sure to use `function () { ... }` callbacks. Otherwise the test engine will NOT have `this` pointing at the test context.\n\n```\ndescribe('User page', () => {  beforeEach(function () {    // \"this\" points at the test context object    cy.fixture('user').then((user) => {      // \"this\" is still the test context object      this.user = user    })  })  // the test callback is in \"function () { ... }\" form  it('has user', function () {    // this.user exists    expect(this.user.firstName).to.equal('Jane')  })})\n```\n\n### Loaded just once\n\nPlease keep in mind that fixture files are assumed to be unchanged during the test, and thus Cypress loads them just once. Even if you overwrite the fixture file itself, the already loaded fixture data remains the same.\n\nIf you wish to dynamically change the contents of a file during your tests, consider [`cy.readFile()`](/llm/markdown/api/commands/readfile.md) instead.\n\nFor example, if you want to reply to a network request with different object, the following **will not work**:\n\n```\n// 🚨 DOES NOT WORKcy.intercept('GET', '/todos/1', { fixture: 'todo' }).as('todo')// application requests the /todos/1 resource// the intercept replies with the object from todo.json filecy.wait('@todo').then(() => {  cy.writeFile('/cypress/fixtures/todo.json', { title: 'New data' })})// application requests the /todos/1 resource again// the intercept replies with the originally loaded object// from the todo.json file and NOT { \"title\": \"New data\" }\n```\n\nIn this situation, avoid using the fixture file and instead respond to the network request with the object\n\n```\n// ✅ RESPOND WITH OBJECTcy.fixture('todo.json').then((todo) => {  cy.intercept('GET', '/todos/1', { body: todo }).as('todo')  // application requests the /todos/1 resource  // the intercept replies with the initial object  cy.wait('@todo').then(() => {    // modify the response object    todo.title = 'New data'    // and override the intercept    cy.intercept('GET', '/todos/1', { body: todo })  })})\n```\n",
      "section": "api",
      "anchors": [
        "notes"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 603
    },
    {
      "id": "api/commands/fixture#shortcuts",
      "doc_id": "api/commands/fixture",
      "heading": "Shortcuts",
      "heading_level": 3,
      "content_markdown": "### Shortcuts\n\n#### Using the `fixture` `StaticResponse` property\n\nFixtures can also be referenced directly without using the `.fixture()` command by using the special property `fixture` on the [`cy.intercept()`](/llm/markdown/api/commands/intercept.md) `StaticResponse` object.\n\n```\ncy.intercept('GET', '/users/**', { fixture: 'users' })\n```\n",
      "section": "api",
      "anchors": [
        "shortcuts"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 51
    },
    {
      "id": "api/commands/fixture#using-the-fixture-staticresponse-property",
      "doc_id": "api/commands/fixture",
      "heading": "Using the fixture StaticResponse property",
      "heading_level": 4,
      "content_markdown": "#### Using the `fixture` `StaticResponse` property\n\nFixtures can also be referenced directly without using the `.fixture()` command by using the special property `fixture` on the [`cy.intercept()`](/llm/markdown/api/commands/intercept.md) `StaticResponse` object.\n\n```\ncy.intercept('GET', '/users/**', { fixture: 'users' })\n```\n",
      "section": "api",
      "anchors": [
        "using-the-fixture-staticresponse-property"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 48
    },
    {
      "id": "api/commands/fixture#encoding",
      "doc_id": "api/commands/fixture",
      "heading": "Encoding",
      "heading_level": 3,
      "content_markdown": "### Encoding\n\n#### Default Encoding\n\nCypress automatically determines the encoding for the following file types:\n\n*   `.json`\n*   `.js`\n*   `.coffee`\n*   `.html`\n*   `.txt`\n*   `.csv`\n*   `.png`\n*   `.jpg`\n*   `.jpeg`\n*   `.gif`\n*   `.tif`\n*   `.tiff`\n*   `.zip`\n\nFor other types of files, they will be read as `utf8` by default, unless specified in the second argument of `cy.fixture()`. You can specify `null` as the encoding in order to read the file as a [`Cypress.Buffer`](/llm/markdown/api/utilities/buffer.md) instance instead.\n",
      "section": "api",
      "anchors": [
        "encoding"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 107
    },
    {
      "id": "api/commands/fixture#default-encoding",
      "doc_id": "api/commands/fixture",
      "heading": "Default Encoding",
      "heading_level": 4,
      "content_markdown": "#### Default Encoding\n\nCypress automatically determines the encoding for the following file types:\n\n*   `.json`\n*   `.js`\n*   `.coffee`\n*   `.html`\n*   `.txt`\n*   `.csv`\n*   `.png`\n*   `.jpg`\n*   `.jpeg`\n*   `.gif`\n*   `.tif`\n*   `.tiff`\n*   `.zip`\n\nFor other types of files, they will be read as `utf8` by default, unless specified in the second argument of `cy.fixture()`. You can specify `null` as the encoding in order to read the file as a [`Cypress.Buffer`](/llm/markdown/api/utilities/buffer.md) instance instead.\n",
      "section": "api",
      "anchors": [
        "default-encoding"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 104
    },
    {
      "id": "api/commands/fixture#this-context",
      "doc_id": "api/commands/fixture",
      "heading": "this context",
      "heading_level": 3,
      "content_markdown": "### `this` context\n\nIf you store and access the fixture data using `this` test context object, make sure to use `function () { ... }` callbacks. Otherwise the test engine will NOT have `this` pointing at the test context.\n\n```\ndescribe('User page', () => {  beforeEach(function () {    // \"this\" points at the test context object    cy.fixture('user').then((user) => {      // \"this\" is still the test context object      this.user = user    })  })  // the test callback is in \"function () { ... }\" form  it('has user', function () {    // this.user exists    expect(this.user.firstName).to.equal('Jane')  })})\n```\n",
      "section": "api",
      "anchors": [
        "this-context"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 127
    },
    {
      "id": "api/commands/fixture#loaded-just-once",
      "doc_id": "api/commands/fixture",
      "heading": "Loaded just once",
      "heading_level": 3,
      "content_markdown": "### Loaded just once\n\nPlease keep in mind that fixture files are assumed to be unchanged during the test, and thus Cypress loads them just once. Even if you overwrite the fixture file itself, the already loaded fixture data remains the same.\n\nIf you wish to dynamically change the contents of a file during your tests, consider [`cy.readFile()`](/llm/markdown/api/commands/readfile.md) instead.\n\nFor example, if you want to reply to a network request with different object, the following **will not work**:\n\n```\n// 🚨 DOES NOT WORKcy.intercept('GET', '/todos/1', { fixture: 'todo' }).as('todo')// application requests the /todos/1 resource// the intercept replies with the object from todo.json filecy.wait('@todo').then(() => {  cy.writeFile('/cypress/fixtures/todo.json', { title: 'New data' })})// application requests the /todos/1 resource again// the intercept replies with the originally loaded object// from the todo.json file and NOT { \"title\": \"New data\" }\n```\n\nIn this situation, avoid using the fixture file and instead respond to the network request with the object\n\n```\n// ✅ RESPOND WITH OBJECTcy.fixture('todo.json').then((todo) => {  cy.intercept('GET', '/todos/1', { body: todo }).as('todo')  // application requests the /todos/1 resource  // the intercept replies with the initial object  cy.wait('@todo').then(() => {    // modify the response object    todo.title = 'New data'    // and override the intercept    cy.intercept('GET', '/todos/1', { body: todo })  })})\n```\n",
      "section": "api",
      "anchors": [
        "loaded-just-once"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 277
    },
    {
      "id": "api/commands/fixture#rules",
      "doc_id": "api/commands/fixture",
      "heading": "Rules",
      "heading_level": 2,
      "content_markdown": "## Rules\n\n### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)\n\n*   `cy.fixture()` requires being chained off of `cy`.\n\n### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)\n\n*   `cy.fixture()` will only run assertions you have chained once, and will not [retry](/llm/markdown/app/core-concepts/retry-ability.md).\n\n### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `cy.fixture()` should never time out.\n\nBecause `cy.fixture()` is asynchronous it is technically possible for there to be a timeout while talking to the internal Cypress automation APIs. But for practical purposes it should never happen.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 101
    },
    {
      "id": "api/commands/fixture#timeouts-learn-about-timeouts",
      "doc_id": "api/commands/fixture",
      "heading": "Timeouts Learn about timeouts",
      "heading_level": 3,
      "content_markdown": "### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `cy.fixture()` should never time out.\n\nBecause `cy.fixture()` is asynchronous it is technically possible for there to be a timeout while talking to the internal Cypress automation APIs. But for practical purposes it should never happen.\n",
      "section": "api",
      "anchors": [
        "timeouts-learn-about-timeouts"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 55
    },
    {
      "id": "api/commands/fixture#see-also",
      "doc_id": "api/commands/fixture",
      "heading": "See also",
      "heading_level": 2,
      "content_markdown": "## See also\n\n*   [Guide: Variables and Aliases](/llm/markdown/app/core-concepts/variables-and-aliases.md)\n*   [`cy.intercept()`](/llm/markdown/api/commands/intercept.md)\n*   [`.then()`](/llm/markdown/api/commands/then.md)\n*   [`.readFile()`](/llm/markdown/api/commands/readfile.md) for a similar command without caching and with builtin retryability\n*   [Recipe: Bootstrapping App Test Data](/llm/markdown/app/references/recipes.md#Server-Communication)\n",
      "section": "api",
      "anchors": [
        "see-also"
      ],
      "path": "/llm/json/chunked/api/commands/fixture.json",
      "token_estimate": 40
    }
  ]
}