{
  "doc": {
    "id": "api/commands/prevuntil",
    "title": "cy.prevUntil()",
    "description": "Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/prevuntil.md",
    "version": "29f95bf8bb06f320986f3749f5bf09a35a409eab",
    "updated_at": "2026-09-04T10:49:54.630Z",
    "headings": [
      {
        "id": "api/commands/prevuntil#prevuntil",
        "text": "prevUntil",
        "level": 1
      },
      {
        "id": "api/commands/prevuntil#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/prevuntil#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/prevuntil#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/prevuntil#yields",
        "text": "Yields",
        "level": 3
      },
      {
        "id": "api/commands/prevuntil#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/prevuntil#selector",
        "text": "Selector",
        "level": 3
      },
      {
        "id": "api/commands/prevuntil#find-all-of-the-elements-siblings-before-nuts-until-veggies",
        "text": "Find all of the element's siblings before #nuts until #veggies",
        "level": 4
      },
      {
        "id": "api/commands/prevuntil#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/prevuntil#requirements",
        "text": "Requirements",
        "level": 3
      },
      {
        "id": "api/commands/prevuntil#assertions",
        "text": "Assertions",
        "level": 3
      },
      {
        "id": "api/commands/prevuntil#timeouts",
        "text": "Timeouts",
        "level": 3
      },
      {
        "id": "api/commands/prevuntil#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/prevuntil#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/prevuntil#syntax",
      "doc_id": "api/commands/prevuntil",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\n.prevUntil(selector)\n.prevUntil(selector, filter)\n.prevUntil(selector, filter, options)\n.prevUntil(element)\n.prevUntil(element, filter)\n.prevUntil(element, filter, options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.get('p').prevUntil('.intro') // Yield siblings before 'p' until '.intro'\n```\n\n**Incorrect Usage**\n\n```\ncy.prevUntil() // Errors, cannot be chained off 'cy'\ncy.location().prevUntil('path') // Errors, 'location' does not yield DOM element\n```\n\n### Arguments\n\n**selector _(String selector)_**\n\nThe selector where you want finding previous siblings to stop.\n\n**element _(DOM node, jQuery Object)_**\n\nThe element where you want finding previous siblings to stop.\n\n**filter _(String selector)_**\n\nA selector used to filter matching DOM elements.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.prevUntil()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.prevUntil()` to resolve before [timing out](#Timeouts) |\n\n### Yields\n\n*   `.prevUntil()` yields the new DOM element(s) it found.\n*   `.prevUntil()` is a query, and it is _safe_ to chain further commands.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/prevuntil.json",
      "token_estimate": 231
    },
    {
      "id": "api/commands/prevuntil#usage",
      "doc_id": "api/commands/prevuntil",
      "heading": "Usage",
      "heading_level": 3,
      "content_markdown": "### Usage\n\n**Correct Usage**\n\n```\ncy.get('p').prevUntil('.intro') // Yield siblings before 'p' until '.intro'\n```\n\n**Incorrect Usage**\n\n```\ncy.prevUntil() // Errors, cannot be chained off 'cy'\ncy.location().prevUntil('path') // Errors, 'location' does not yield DOM element\n```\n",
      "section": "api",
      "anchors": [
        "usage"
      ],
      "path": "/llm/json/chunked/api/commands/prevuntil.json",
      "token_estimate": 47
    },
    {
      "id": "api/commands/prevuntil#arguments",
      "doc_id": "api/commands/prevuntil",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**selector _(String selector)_**\n\nThe selector where you want finding previous siblings to stop.\n\n**element _(DOM node, jQuery Object)_**\n\nThe element where you want finding previous siblings to stop.\n\n**filter _(String selector)_**\n\nA selector used to filter matching DOM elements.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.prevUntil()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.prevUntil()` to resolve before [timing out](#Timeouts) |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/prevuntil.json",
      "token_estimate": 131
    },
    {
      "id": "api/commands/prevuntil#examples",
      "doc_id": "api/commands/prevuntil",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### Selector\n\n#### Find all of the element's siblings before `#nuts` until `#veggies`\n\n```\n<ul>\n  <li id=\"fruits\" class=\"header\">Fruits</li>\n  <li>apples</li>\n  <li>oranges</li>\n  <li>bananas</li>\n  <li id=\"veggies\" class=\"header\">Vegetables</li>\n  <li>cucumbers</li>\n  <li>carrots</li>\n  <li>corn</li>\n  <li id=\"nuts\" class=\"header\">Nuts</li>\n  <li>walnuts</li>\n  <li>cashews</li>\n  <li>almonds</li>\n</ul>\n```\n\n```\n// yields [<li>cucumbers</li>, <li>carrots</li>, <li>corn</li>]\ncy.get('#nuts').prevUntil('#veggies')\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/prevuntil.json",
      "token_estimate": 60
    },
    {
      "id": "api/commands/prevuntil#selector",
      "doc_id": "api/commands/prevuntil",
      "heading": "Selector",
      "heading_level": 3,
      "content_markdown": "### Selector\n\n#### Find all of the element's siblings before `#nuts` until `#veggies`\n\n```\n<ul>\n  <li id=\"fruits\" class=\"header\">Fruits</li>\n  <li>apples</li>\n  <li>oranges</li>\n  <li>bananas</li>\n  <li id=\"veggies\" class=\"header\">Vegetables</li>\n  <li>cucumbers</li>\n  <li>carrots</li>\n  <li>corn</li>\n  <li id=\"nuts\" class=\"header\">Nuts</li>\n  <li>walnuts</li>\n  <li>cashews</li>\n  <li>almonds</li>\n</ul>\n```\n\n```\n// yields [<li>cucumbers</li>, <li>carrots</li>, <li>corn</li>]\ncy.get('#nuts').prevUntil('#veggies')\n```\n",
      "section": "api",
      "anchors": [
        "selector"
      ],
      "path": "/llm/json/chunked/api/commands/prevuntil.json",
      "token_estimate": 57
    },
    {
      "id": "api/commands/prevuntil#find-all-of-the-elements-siblings-before-nuts-until-veggies",
      "doc_id": "api/commands/prevuntil",
      "heading": "Find all of the element's siblings before #nuts until #veggies",
      "heading_level": 4,
      "content_markdown": "#### Find all of the element's siblings before `#nuts` until `#veggies`\n\n```\n<ul>\n  <li id=\"fruits\" class=\"header\">Fruits</li>\n  <li>apples</li>\n  <li>oranges</li>\n  <li>bananas</li>\n  <li id=\"veggies\" class=\"header\">Vegetables</li>\n  <li>cucumbers</li>\n  <li>carrots</li>\n  <li>corn</li>\n  <li id=\"nuts\" class=\"header\">Nuts</li>\n  <li>walnuts</li>\n  <li>cashews</li>\n  <li>almonds</li>\n</ul>\n```\n\n```\n// yields [<li>cucumbers</li>, <li>carrots</li>, <li>corn</li>]\ncy.get('#nuts').prevUntil('#veggies')\n```\n",
      "section": "api",
      "anchors": [
        "find-all-of-the-elements-siblings-before-nuts-until-veggies"
      ],
      "path": "/llm/json/chunked/api/commands/prevuntil.json",
      "token_estimate": 55
    },
    {
      "id": "api/commands/prevuntil#rules",
      "doc_id": "api/commands/prevuntil",
      "heading": "Rules",
      "heading_level": 2,
      "content_markdown": "## Rules\n\n### Requirements\n\n*   `.prevUntil()` requires being chained off a command that yields DOM element(s).\n\n### Assertions\n\n*   `.prevUntil()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until the element(s) [exist in the DOM](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Implicit-Assertions).\n*   `.prevUntil()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until all chained assertions have passed.\n\n### Timeouts\n\n*   `.prevUntil()` can time out waiting for the element(s) to [exist in the DOM](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Implicit-Assertions).\n*   `.prevUntil()` can time out waiting for assertions you've added to pass.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/prevuntil.json",
      "token_estimate": 92
    },
    {
      "id": "api/commands/prevuntil#command-log",
      "doc_id": "api/commands/prevuntil",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\n**_Find all of the element's siblings before `#nuts` until `#veggies`_**\n\n```\ncy.get('#nuts').prevUntil('#veggies')\n```\n\nThe commands above will display in the Command Log as:\n\nWhen clicking on `prevUntil` within the command log, the console outputs the following:\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/prevuntil.json",
      "token_estimate": 52
    }
  ]
}