histoire
Version:
A fast story book powered by Vite
27 lines • 1.05 kB
TypeScript
import type { RequestHandler } from 'msw';
/** Logs a mocked request, e.g. to the Events panel. */
type NetworkLogger = (name: string, data: {
method: string;
url: string;
status: number;
}) => void;
/**
* Creates the network mocking API of `histoire/client`: `window.fetch` is
* answered by msw request handlers, without a service worker. Requests no
* handler answers reach the previous `window.fetch` unchanged.
* @param log Called for every mocked response.
*/
export declare function createNetworkMock(log: NetworkLogger): {
/**
* Replaces the handlers of the current variant. Call it from a variant's
* `setupApp`, so they exist before the story mounts and fetches.
*/
mockNetwork(...handlers: RequestHandler[]): void;
/**
* Replaces the handlers answering every story. Call it at the top level of
* the setup file, so they also answer requests made while the app boots.
*/
mockNetworkDefaults(...handlers: RequestHandler[]): void;
};
export {};
//# sourceMappingURL=network.d.ts.map