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 it considers fetch
just as a function call instead of calls to endpoints. vi-fetch
provides matchers to test calls to endpoints instead of simply function calls. For example, we consider an endpoint to be URL until the first ?
, query is like arguments to an endpoint, just like body
- that's why we provide matchers like toHaveFetchedWithQuery
.
Docs
Read full docs on GitHub.