{
  "doc": {
    "id": "api/commands/spread",
    "title": "spread | Cypress Documentation",
    "description": "Expand an array into multiple arguments in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/spread.md",
    "version": "a8fd16711bdda4c7b5645b9717e588ae99ec2470",
    "updated_at": "2026-05-18T17:21:32.047Z",
    "headings": [
      {
        "id": "api/commands/spread#spread",
        "text": "spread",
        "level": 1
      },
      {
        "id": "api/commands/spread#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/spread#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/spread#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/spread#yields-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "level": 3
      },
      {
        "id": "api/commands/spread#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/spread#aliased-routes",
        "text": "Aliased Routes",
        "level": 3
      },
      {
        "id": "api/commands/spread#expand-the-array-of-aliased-routes",
        "text": "Expand the array of aliased routes",
        "level": 4
      },
      {
        "id": "api/commands/spread#cookies",
        "text": "Cookies",
        "level": 3
      },
      {
        "id": "api/commands/spread#expand-the-array-of-cookies",
        "text": "Expand the array of cookies",
        "level": 4
      },
      {
        "id": "api/commands/spread#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/spread#requirements-learn-about-chaining-commands",
        "text": "Requirements Learn about chaining commands",
        "level": 3
      },
      {
        "id": "api/commands/spread#assertions-learn-about-assertions",
        "text": "Assertions Learn about assertions",
        "level": 3
      },
      {
        "id": "api/commands/spread#timeouts-learn-about-timeouts",
        "text": "Timeouts Learn about timeouts",
        "level": 3
      },
      {
        "id": "api/commands/spread#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/spread#history",
        "text": "History",
        "level": 2
      },
      {
        "id": "api/commands/spread#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/spread#syntax",
      "doc_id": "api/commands/spread",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\n.spread(callbackFn).spread(options, callbackFn)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.getCookies().spread(() => {}) // Yield all cookies\n```\n\n**Incorrect Usage**\n\n```\ncy.spread(() => {}) // Errors, cannot be chained off 'cy'cy.clock().spread() // Errors, 'clock' does not yield an array\n```\n\n### Arguments\n\n**fn _(Function)_**\n\nPass a function that expands the array into its arguments.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.spread()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.spread()` 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*   `.spread()` yields the return value of your callback function.\n*   `.spread()` wlll not change the subject if `null` or `undefined` is returned.\n*   If the returned values are DOM elements, it is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the subject after `.spread()`.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/spread.json",
      "token_estimate": 200
    },
    {
      "id": "api/commands/spread#usage",
      "doc_id": "api/commands/spread",
      "heading": "Usage",
      "heading_level": 3,
      "content_markdown": "### Usage\n\n**Correct Usage**\n\n```\ncy.getCookies().spread(() => {}) // Yield all cookies\n```\n\n**Incorrect Usage**\n\n```\ncy.spread(() => {}) // Errors, cannot be chained off 'cy'cy.clock().spread() // Errors, 'clock' does not yield an array\n```\n",
      "section": "api",
      "anchors": [
        "usage"
      ],
      "path": "/llm/json/chunked/api/commands/spread.json",
      "token_estimate": 47
    },
    {
      "id": "api/commands/spread#arguments",
      "doc_id": "api/commands/spread",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**fn _(Function)_**\n\nPass a function that expands the array into its arguments.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.spread()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.spread()` to resolve before [timing out](#Timeouts) |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/spread.json",
      "token_estimate": 77
    },
    {
      "id": "api/commands/spread#yields-learn-about-subject-management",
      "doc_id": "api/commands/spread",
      "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*   `.spread()` yields the return value of your callback function.\n*   `.spread()` wlll not change the subject if `null` or `undefined` is returned.\n*   If the returned values are DOM elements, it is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the subject after `.spread()`.\n",
      "section": "api",
      "anchors": [
        "yields-learn-about-subject-management"
      ],
      "path": "/llm/json/chunked/api/commands/spread.json",
      "token_estimate": 68
    },
    {
      "id": "api/commands/spread#examples",
      "doc_id": "api/commands/spread",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### Aliased Routes\n\n#### Expand the array of aliased routes\n\n```\ncy.intercept('/users/*').as('getUsers')cy.intercept('/activities/*').as('getActivities')cy.intercept('/comments/*').as('getComments')cy.wait(['@getUsers', '@getActivities', '@getComments']).spread(  (getUsers, getActivities, getComments) => {    // each interception is now an individual argument  })\n```\n\n### Cookies\n\n#### Expand the array of cookies\n\n```\ncy.getCookies().spread((cookie1, cookie2, cookie3) => {  // each cookie is now an individual argument})\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/spread.json",
      "token_estimate": 72
    },
    {
      "id": "api/commands/spread#rules",
      "doc_id": "api/commands/spread",
      "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*   `.spread()` requires being chained off a previous command.\n*   `.spread()` requires being chained off a command that yields an array-like structure.\n\n### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)\n\n*   `.spread()` 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*   `.spread()` can time out waiting for a promise you've returned to resolve.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/spread.json",
      "token_estimate": 89
    }
  ]
}