2.0.1 • Published 5 years ago

fetchception v2.0.1

Weekly downloads
56
License
ISC
Repository
-
Last release
5 years ago

fetchception

npm version Build Status

Mock out network traffic from fetch in tests. Experiment based on idea from fileception and httpception. Utilizing the great modelling, inspection and diffing of HTTP conversations from messy and unexpected-messy.

const fetchception = require("fetchception");
const assert = require("assert");

it("should cleanly mock out fetch in the test", () =>
  fetchception(
    [
      {
        request: "/api/foo",
        response: {
          statusCode: 200,
          body: { foo: "bar" },
        },
      },
    ],
    () => {
      return fetch("/api/foo")
        .then((res) => res.json())
        .then((res) => {
          assert.strictEqual(res.foo, "bar");
        });
    }
  ));

When the test is done, the fetch global will automatically be restored.

2.0.1

5 years ago

2.0.0

5 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.6.1

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.0

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago