{
  "doc": {
    "id": "api/utilities/minimatch",
    "title": "Cypress.minimatch | Cypress Documentation",
    "description": "Cypress automatically includes minimatch and exposes it as `Cypress.minimatch`.",
    "section": "api",
    "source_path": "/llm/markdown/api/utilities/minimatch.md",
    "version": "ce02913654e2655ee63448bdc92bb92c7b46a619",
    "updated_at": "2026-04-22T19:37:51.587Z",
    "headings": [
      {
        "id": "api/utilities/minimatch#cypress-minimatch",
        "text": "Cypress.minimatch",
        "level": 1
      },
      {
        "id": "api/utilities/minimatch#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/utilities/minimatch#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/utilities/minimatch#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/utilities/minimatch#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "content": {
    "type": "root",
    "children": [
      {
        "type": "heading",
        "depth": 1,
        "children": [
          {
            "type": "text",
            "value": "Cypress.minimatch"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Cypress automatically includes "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://github.com/isaacs/minimatch",
            "children": [
              {
                "type": "text",
                "value": "minimatch"
              }
            ]
          },
          {
            "type": "text",
            "value": "\nand exposes it as `Cypress.minimatch`."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Use `Cypress.minimatch` to test out glob patterns against strings."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Syntax"
          }
        ]
      },
      {
        "type": "code",
        "lang": "javascript",
        "meta": null,
        "value": "Cypress.minimatch(target: string, pattern: string, options?: MinimatchOptions);"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Usage"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Correct Usage"
          }
        ]
      },
      {
        "type": "code",
        "lang": "javascript",
        "meta": null,
        "value": "Cypress.minimatch('/users/1/comments/2', '/users/*/comments', {\n  matchBase: true,\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Incorrect Usage"
          }
        ]
      },
      {
        "type": "code",
        "lang": "javascript",
        "meta": null,
        "value": "cy.minimatch() // Errors, cannot be chained off 'cy'"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Examples"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "By default Cypress uses `minimatch` to test glob patterns against request URLs."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If you're struggling with writing the correct pattern you can iterate much\nfaster by testing directly in your Developer Tools console."
          }
        ]
      },
      {
        "type": "code",
        "lang": "javascript",
        "meta": null,
        "value": "// test that the glob you're writing matches the request's url\n\n// returns true\nCypress.minimatch('/users/1/comments', '/users/*/comments', {\n  matchBase: true,\n})\n\n// returns false\nCypress.minimatch('/users/1/comments/2', '/users/*/comments', {\n  matchBase: true,\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "We're adding the `{ matchBase: true }` option because under the hood Cypress\nactually uses that option by default."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Now let's test out `**` support."
          }
        ]
      },
      {
        "type": "code",
        "lang": "javascript",
        "meta": null,
        "value": "// ** matches against all downstream path segments\n\n// returns true\nCypress.minimatch('/foo/bar/baz/123/quux?a=b&c=2', '/foo/**', {\n  matchBase: true,\n})\n\n// whereas * matches only the next path segment\n\n// returns false\nCypress.minimatch('/foo/bar/baz/123/quux?a=b&c=2', '/foo/*', {\n  matchBase: false,\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": 251
}