msw-vcr
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

msw-vcr

msw wrapper to record and replay network requests

Usage

import { setupServer } from "msw-vcr";

async function exampleGithubFetch() {
  return fetch("https://api.github.com/orgs/nodejs", {
    credentials: "include",
    headers: {
      Accept: "application/json",
      "Content-Type": "application/json",
    },
  }).then((response) => response.json() as Promise<unknown>);
}

const cassetteDir = path.join(__dirname, "vcr");

const vcr = setupServer({
  cassetteDir: cassetteDir,
  onUnhandledRequest: process.env['VCR'] ? "record" : "error",
});

await vcr.cassette("github", exampleGithubFetch);

/msw-vcr/

    Package Sidebar

    Install

    npm i msw-vcr

    Weekly Downloads

    2

    Version

    0.0.4

    License

    ISC

    Unpacked Size

    22.1 kB

    Total Files

    9

    Last publish

    Collaborators

    • pigoz