stoobly
    Preparing search index...

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    headers: Record<string, string> = {}
    urls: InterceptorUrl[] = []
    originalFetch:
        | (input: RequestInfo | URL, init?: RequestInit) => Promise<Response> & {
            (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
            (input: string | Request | URL, init?: RequestInit): Promise<Response>;
        }
        | null = ...

    Type Declaration

    • (input: RequestInfo | URL, init?: RequestInit) => Promise<Response> & {
          (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
          (input: string | Request | URL, init?: RequestInit): Promise<Response>;
      }
        • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
        • Parameters

          • input: RequestInfo | URL
          • Optionalinit: RequestInit

          Returns Promise<Response>

        • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
        • Parameters

          • input: RequestInfo | URL
          • Optionalinit: RequestInit

          Returns Promise<Response>

        • (input: string | Request | URL, init?: RequestInit): Promise<Response>
        • Parameters

          • input: string | Request | URL
          • Optionalinit: RequestInit

          Returns Promise<Response>

    • null
    originalXMLHttpRequestOpen:
        | {
            (method: string, url: string | URL): void;
            (
                method: string,
                url: string | URL,
                async: boolean,
                username?: string | null,
                password?: string | null,
            ): void;
        }
        | null = ...

    Type Declaration

    • {
          (method: string, url: string | URL): void;
          (
              method: string,
              url: string | URL,
              async: boolean,
              username?: string | null,
              password?: string | null,
          ): void;
      }
        • (method: string, url: string | URL): void
        • Sets the request method, request URL, and synchronous flag.

          Throws a "SyntaxError" DOMException if either method is not a valid method or url cannot be parsed.

          Throws a "SecurityError" DOMException if method is a case-insensitive match for CONNECT, TRACE, or TRACK.

          Throws an "InvalidAccessError" DOMException if async is false, current global object is a Window object, and the timeout attribute is not zero or the responseType attribute is not the empty string.

          MDN Reference

          Parameters

          • method: string
          • url: string | URL

          Returns void

        • (
              method: string,
              url: string | URL,
              async: boolean,
              username?: string | null,
              password?: string | null,
          ): void
        • Parameters

          • method: string
          • url: string | URL
          • async: boolean
          • Optionalusername: string | null
          • Optionalpassword: string | null

          Returns void

    • null

    Accessors

    Methods

    • Conditionally applies matchRules, rewriteRules, publicDirectoryPath, and responseFixturesPath headers from the matching InterceptorUrl when the request URL matches a pattern with these options set.

      Parameters

      Returns void

    • Parameters

      • initialHeaders: Record<string, string>

      Returns { [key: string]: string }

    • Filters out the overwrite record order header after the first request to each URL pattern.

      The overwrite header (RECORD_ORDER and OVERWRITE_ID) should only be sent once per URL pattern in this.urls, not once per actual request URL. This method mutates the urlsToVisit array to track which patterns have already been visited.

      Implementation notes:

      • urlsToVisit is a copy of this.urls created when the interceptor is decorated
      • Each request removes its matching pattern from urlsToVisit
      • When urlsToVisit is empty or pattern not found, both RECORD_ORDER and OVERWRITE_ID are removed from subsequent requests

      Pattern matching:

      • String patterns: Direct equality check (url === urlPattern)
      • RegExp patterns: Pattern test against the actual URL

      Lifecycle safety:

      • For fetch/XHR: urlsToVisit is created once per decorate() call and shared across all intercepted requests. This is safe because restore() removes the interceptor and decorate() creates a fresh urlsToVisit.
      • For Playwright: urlsToVisit is created per decoratePlaywright() call. When withPage() is called with a different page (e.g., in beforeEach), the old handlers are cleaned up via restore() and new handlers with fresh urlsToVisit are created.
      • For Cypress: Same lifecycle as Playwright - decorateCypress() creates fresh urlsToVisit and restore() cleans up old interceptors.

      Example: this.urls = [{ pattern: //api/.+/ }, { pattern: 'https://example.com/exact' }]

      Request 1 to /api/users - matches first pattern, removes from urlsToVisit, includes headers Request 2 to /api/posts - pattern already removed, omits overwrite headers Request 3 to exact URL - matches second pattern, removes from urlsToVisit, includes headers Request 4 to exact URL - pattern already removed, omits overwrite headers

      Parameters

      • headers: Record<string, string>

        The headers object to potentially modify

      • url: string | RegExp

        The URL or URL pattern being requested (actual URL for fetch/XHR, pattern for Playwright/Cypress)

      • urlsToVisit: (string | RegExp)[]

        Mutable array of URL patterns that haven't been visited yet

      Returns void