{
  "doc": {
    "id": "api/utilities/lodash",
    "title": "Cypress._",
    "description": "Cypress automatically includes lodash and exposes it as Cypress._.",
    "section": "api",
    "source_path": "/llm/markdown/api/utilities/lodash.md",
    "version": "29f95bf8bb06f320986f3749f5bf09a35a409eab",
    "updated_at": "2026-09-04T10:49:54.630Z",
    "headings": [
      {
        "id": "api/utilities/lodash#cypress",
        "text": "Cypress._",
        "level": 1
      },
      {
        "id": "api/utilities/lodash#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/utilities/lodash#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/utilities/lodash#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/utilities/lodash#each",
        "text": "_.each",
        "level": 3
      },
      {
        "id": "api/utilities/lodash#chain",
        "text": "_.chain",
        "level": 3
      },
      {
        "id": "api/utilities/lodash#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "content": {
    "type": "root",
    "children": [
      {
        "type": "heading",
        "depth": 1,
        "children": [
          {
            "type": "text",
            "value": "Cypress._"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Cypress automatically includes "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://lodash.com/",
            "children": [
              {
                "type": "text",
                "value": "lodash"
              }
            ]
          },
          {
            "type": "text",
            "value": " and exposes it as `Cypress._`. Call any valid Lodash method on `Cypress._`"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Syntax"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "Cypress._.method()"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Usage"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Correct Usage"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "Cypress._.keys(obj)"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Incorrect Usage"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy._.keys(obj) // Errors, cannot be chained off 'cy'"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Examples"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "`_.each`"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// set local reference to lodash and jquery\nconst { _, $ } = Cypress\n\ncy.get('li').then(($li) => {\n  // use the _.each function\n  _.each($li.get(), (el, i) => {\n    // use $(...) to wrap the DOM element\n    // into a jQuery object\n    expect($(el).parent()).to.match('ul')\n  })\n})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "`_.chain`"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy\n  // use the _.chain, _.map, _.take, and _.value functions\n  .request('http://jsonplaceholder.typicode.com/users')\n  .then((response) => {\n    const ids = Cypress._.chain(response.body).map('id').take(3).value()\n\n    expect(ids).to.deep.eq([1, 2, 3])\n  })"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "See also"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/bundled-libraries.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "Bundled Libraries"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  },
  "token_estimate": 165
}