{
  "doc": {
    "id": "api/utilities/$",
    "title": "Cypress.$",
    "description": "Cypress automatically includes jQuery and exposes it as Cypress.$.",
    "section": "api",
    "source_path": "/llm/markdown/api/utilities/$.md",
    "version": "efcbe8c28d49ff52285a47072f279cb65f20c0fc",
    "updated_at": "2026-09-09T13:41:20.773Z",
    "headings": [
      {
        "id": "api/utilities/$#cypress",
        "text": "Cypress.$",
        "level": 1
      },
      {
        "id": "api/utilities/$#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/utilities/$#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/utilities/$#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/utilities/$#selector",
        "text": "Selector",
        "level": 3
      },
      {
        "id": "api/utilities/$#notes",
        "text": "Notes",
        "level": 2
      },
      {
        "id": "api/utilities/$#cypress-runs-immediately-and-does-not-wait-for-cy-commands",
        "text": "Cypress.$ runs immediately and does not wait for cy commands",
        "level": 3
      },
      {
        "id": "api/utilities/$#cypress-vs-cy",
        "text": "Cypress.$ vs. cy.$$",
        "level": 3
      },
      {
        "id": "api/utilities/$#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": "http://jquery.com",
            "children": [
              {
                "type": "text",
                "value": "jQuery"
              }
            ]
          },
          {
            "type": "text",
            "value": " and exposes it as `Cypress.$`."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "This is a great way to synchronously query for elements when debugging from Developer Tools."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Syntax"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "Cypress.$(selector)\n\n// other proxied jQuery methods\nCypress.$.Event\nCypress.$.Deferred\nCypress.$.ajax\nCypress.$.get\nCypress.$.getJSON\nCypress.$.getScript\nCypress.$.post"
      },
      {
        "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.$('p')"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Incorrect Usage"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.$('p') // Errors, cannot be chained off 'cy'"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Examples"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Selector"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "const $li = Cypress.$('ul li:first')\n\ncy.wrap($li)\n  .should('not.have.class', 'active')\n  .click()\n  .should('have.class', 'active')"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Notes"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Cypress.$ runs immediately and does not wait for `cy` commands"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`Cypress.$` queries the application under test's DOM synchronously, at the moment the line of code runs. Unlike "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/get.md",
            "children": [
              {
                "type": "text",
                "value": "`cy.get()`"
              }
            ]
          },
          {
            "type": "text",
            "value": ", it is not a queued command and does not wait for previous `cy` commands to finish."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.visit('/page-with-list')\n// runs immediately, before cy.visit() has navigated, so it queries the\n// previous (blank) page and returns an empty jQuery object: [jQuery{0}]\nconst $items = Cypress.$('li')"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "To query the DOM after prior commands have run, move the query into a "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/then.md",
            "children": [
              {
                "type": "text",
                "value": "`.then()`"
              }
            ]
          },
          {
            "type": "text",
            "value": " callback, which Cypress defers until the preceding commands finish, or query off an element yielded by `cy`:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.visit('/page-with-list')\ncy.get('body').then(($body) => {\n  // runs after cy.visit() has finished and the page has rendered\n  const $items = $body.find('li')\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If you reached for `Cypress.$` to conditionally do something based on whether an element exists, read the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/guides/conditional-testing.md",
            "children": [
              {
                "type": "text",
                "value": "Conditional Testing"
              }
            ]
          },
          {
            "type": "text",
            "value": " guide first. The DOM must be in a known, stable state for this to be reliable."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Cypress.$ vs. cy.$$"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can also query DOM elements with `cy.$$`. But `Cypress.$` and `cy.$$` are different."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`Cypress.$` refers to the `jQuery` function itself. You can do anything with `Cypress.$` if you can do it with the `jQuery` function. So, both of the examples below work."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "Cypress.$.each([1, 2, 3], (index, value) => {\n  expect(index).to.eq(value)\n}) // works"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "$.each([1, 2, 3], (index, value) => {\n  expect(index).to.eq(value)\n}) // also works"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "But `cy.$$` is a wrapper of the `jQuery.fn.init` function. In other words, you can only query DOM elements with `cy.$$`. Because of that, the jQuery utility functions like `jQuery.each`, `jQuery.grep` don't work with `cy.$$`."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.$$.each([1, 2, 3], (index, value) => {\n  expect(index).to.eq(value)\n}) // fails"
      },
      {
        "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": 495
}