Backstage
    Preparing search index...

    The options given when constructing a MockFetchApi.

    interface MockFetchApiOptions {
        baseImplementation?:
            | {
                (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
                (input: string | Request | URL, init?: RequestInit): Promise<Response>;
            }
            | "none";
        injectIdentityAuth?: | { token: string }
        | { identityApi: Pick<IdentityApi, "getCredentials"> };
        resolvePluginProtocol?: { discoveryApi: Pick<DiscoveryApi, "getBaseUrl"> };
    }
    Index

    Properties

    baseImplementation?:
        | {
            (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
            (input: string | Request | URL, init?: RequestInit): Promise<Response>;
        }
        | "none"

    Define the underlying base fetch implementation.

    Type Declaration

    • {
          (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: string | Request | URL, init?: RequestInit): Promise<Response>
        • Parameters

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

          Returns Promise<Response>

    • "none"
    undefined
    

    Leaving out this parameter or passing undefined, makes the API use the global fetch implementation to make real network requests.

    'none' swallows all calls and makes no requests at all.

    You can also pass in any fetch compatible callback, such as a jest.fn(), if you want to use a custom implementation or to just track and assert on calls.

    injectIdentityAuth?:
        | { token: string }
        | { identityApi: Pick<IdentityApi, "getCredentials"> }

    Add token based Authorization headers to requests, basically simulating what @backstage/core-app-api#FetchMiddlewares.injectIdentityAuth does.

    undefined
    

    Leaving out this parameter or passing undefined, disables auth injection.

    To enable the feature, pass in either a static token or an identity API which is queried on each request for a token.

    resolvePluginProtocol?: { discoveryApi: Pick<DiscoveryApi, "getBaseUrl"> }

    Add translation from plugin:// URLs to concrete http(s) URLs, basically simulating what @backstage/core-app-api#FetchMiddlewares.resolvePluginProtocol does.

    undefined
    

    Leaving out this parameter or passing undefined, disables plugin protocol translation.

    To enable the feature, pass in a discovery API which is then used to resolve the URLs.