{
  "doc": {
    "id": "api/utilities/minimatch",
    "title": "Cypress.minimatch()",
    "description": "Cypress automatically includes minimatch and exposes it as Cypress.minimatch.",
    "section": "api",
    "source_path": "/llm/markdown/api/utilities/minimatch.md",
    "version": "fbc9225067c51c52ee13224e3b702cf8a025ec12",
    "updated_at": "2026-08-14T12:36:26.878Z",
    "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#notes",
        "text": "Notes",
        "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": " and 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": null,
        "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": null,
        "meta": null,
        "value": "Cypress.minimatch('/users/1/comments/2', '/users/*/comments', {  matchBase: true,})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Incorrect Usage"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "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 faster by testing directly in your Developer Tools console."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// test that the glob you're writing matches the request's url// returns trueCypress.minimatch('/users/1/comments', '/users/*/comments', {  matchBase: true,})// returns falseCypress.minimatch('/users/1/comments/2', '/users/*/comments', {  matchBase: true,})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "We're adding the `{ matchBase: true }` option because under the hood Cypress actually uses that option by default."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Now let's test out `**` support."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// ** matches against all downstream path segments// returns trueCypress.minimatch('/foo/bar/baz/123/quux?a=b&c=2', '/foo/**', {  matchBase: true,})// whereas * matches only the next path segment// returns falseCypress.minimatch('/foo/bar/baz/123/quux?a=b&c=2', '/foo/*', {  matchBase: false,})"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Notes"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "In minimatch glob syntax, `?` is a wildcard that matches any single character — it does not represent a literal `?`. If your pattern needs to match the literal `?` that precedes a URL query string, escape it with a backslash. In a JavaScript string you write `\\\\?` so that minimatch receives the character sequence `\\?`:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// INCORRECT – unescaped ? is a wildcard, not a literal question markCypress.minimatch('/users?_limit=3', '/users?_limit=*', { matchBase: true })// false — the ? in the pattern matches any single character, not the// literal ? in the URL// CORRECT – \\\\? sends \\? to minimatch, which matches a literal ?Cypress.minimatch('/users?_limit=3', '/users\\\\?_limit=*', {  matchBase: true,}) // true"
      },
      {
        "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"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/commands/intercept.md#Glob-Pattern-Matching-URLs",
                    "children": [
                      {
                        "type": "text",
                        "value": "cy.intercept() – Glob Pattern Matching URLs"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  },
  "token_estimate": 393
}