npm.io
0.8.0 • Published 3 years ago

vi-fetch

Licence
MIT
Version
0.8.0
Deps
2
Size
38 kB
Vulns
0
Weekly
0
Stars
56
DeprecatedThis package is deprecated

vi-fetch

Easiest way to mock fetch

Compatible with Vitest and Jest when using ESM flag or with transform for /node_modules/vi-fetch.

The main difference with fetch-mock or fetch-mock-jest is that they consider fetch just as a function call instead of function that calls API endpoints. vi-fetch provides matchers to test calls to endpoints instead of simply function calls.

For example, we consider an endpoint to be a part of URL until the first ?: query is an argument to an endpoint, just like body, - that's why we provide matchers like toHaveFetchedWithQuery and toHaveFetchedWithBody.

Docs

Read full docs on GitHub.