Overview of fetch-mock features
mainfetch-mock is a library designed to mock the fetch API with high fidelity. Key capabilities include:
- High Fidelity Mocking: Mocks most of the fetch API spec, including advanced behaviors like streaming and aborting.
- Declarative Matching: Match HTTP requests based on URL, headers, body, and query parameters.
- Shorthands: Provides easy syntax for common tasks, such as matching specific HTTP methods or limiting a mock to a single fetch call.
- Advanced Timing Control: Support for delaying responses or using custom async functions to simulate specific race conditions.
- Spying: Can be used as a spy to observe real network requests without intercepting them.
- Extensibility: Allows creating custom reusable matchers for both matching fetch calls and inspecting results.
- Isomorphic Support: Works in both Node.js and browsers, supporting either a global
fetchinstance or a locally required instance.