{
  "doc": {
    "id": "api/commands/spread",
    "title": "cy.spread()",
    "description": "Expand an array into multiple arguments in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/spread.md",
    "version": "29f95bf8bb06f320986f3749f5bf09a35a409eab",
    "updated_at": "2026-09-04T10:49:54.630Z",
    "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",
        "text": "Yields",
        "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",
        "text": "Requirements",
        "level": 3
      },
      {
        "id": "api/commands/spread#assertions",
        "text": "Assertions",
        "level": 3
      },
      {
        "id": "api/commands/spread#timeouts",
        "text": "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)\n.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'\ncy.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\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": 197
    },
    {
      "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'\ncy.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": 48
    },
    {
      "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",
      "doc_id": "api/commands/spread",
      "heading": "Yields",
      "heading_level": 3,
      "content_markdown": "### Yields\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"
      ],
      "path": "/llm/json/chunked/api/commands/spread.json",
      "token_estimate": 63
    },
    {
      "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')\ncy.intercept('/activities/*').as('getActivities')\ncy.intercept('/comments/*').as('getComments')\ncy.wait(['@getUsers', '@getActivities', '@getComments']).spread(\n  (getUsers, getActivities, getComments) => {\n    // each interception is now an individual argument\n  }\n)\n```\n\n### Cookies\n\n#### Expand the array of cookies\n\n```\ncy.getCookies().spread((cookie1, cookie2, cookie3) => {\n  // each cookie is now an individual argument\n})\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/spread.json",
      "token_estimate": 79
    },
    {
      "id": "api/commands/spread#aliased-routes",
      "doc_id": "api/commands/spread",
      "heading": "Aliased Routes",
      "heading_level": 3,
      "content_markdown": "### Aliased Routes\n\n#### Expand the array of aliased routes\n\n```\ncy.intercept('/users/*').as('getUsers')\ncy.intercept('/activities/*').as('getActivities')\ncy.intercept('/comments/*').as('getComments')\ncy.wait(['@getUsers', '@getActivities', '@getComments']).spread(\n  (getUsers, getActivities, getComments) => {\n    // each interception is now an individual argument\n  }\n)\n```\n",
      "section": "api",
      "anchors": [
        "aliased-routes"
      ],
      "path": "/llm/json/chunked/api/commands/spread.json",
      "token_estimate": 44
    },
    {
      "id": "api/commands/spread#expand-the-array-of-aliased-routes",
      "doc_id": "api/commands/spread",
      "heading": "Expand the array of aliased routes",
      "heading_level": 4,
      "content_markdown": "#### Expand the array of aliased routes\n\n```\ncy.intercept('/users/*').as('getUsers')\ncy.intercept('/activities/*').as('getActivities')\ncy.intercept('/comments/*').as('getComments')\ncy.wait(['@getUsers', '@getActivities', '@getComments']).spread(\n  (getUsers, getActivities, getComments) => {\n    // each interception is now an individual argument\n  }\n)\n```\n",
      "section": "api",
      "anchors": [
        "expand-the-array-of-aliased-routes"
      ],
      "path": "/llm/json/chunked/api/commands/spread.json",
      "token_estimate": 40
    },
    {
      "id": "api/commands/spread#rules",
      "doc_id": "api/commands/spread",
      "heading": "Rules",
      "heading_level": 2,
      "content_markdown": "## Rules\n\n### Requirements\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\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\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": 76
    }
  ]
}