mock-requests
msw-storybook-addon
mock-requests | msw-storybook-addon | |
---|---|---|
4 | 2 | |
35 | 382 | |
- | 3.4% | |
5.4 | 4.9 | |
about 1 year ago | 12 days ago | |
JavaScript | TypeScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
mock-requests
-
What libraries do you use to mock API calls in a React app?
I wrote mock-requests before MSW came out. It was, to my knowledge, the first dev-friendly mocking library out there that didn't involve setting up a separate server yet still allowed dynamic responses. Since MSW came out, I still think mock-requests has a better and simpler API but MSW allows you to see the network request in the browser's dev tools which is super nice IMO.
-
How to mock the return value of an rtk query hook?
I'd mock the network responses from the source. Others already mentioned MSW, but I personally like mock-requests better. I don't need to use a complex config nor chained methods, I still get dynamic responses based on request payload, and I can mock the entire app's requests in a single config object (harking back to not needing complex configuration logic or chained methods).
-
Mocking Axios in Jest when not using shortcut methods?
The companies I worked at were using mock-requests to help them with this and it greatly simplified their testing environment. A single call in a test-setup file meant all network calls for all flows were suddenly mocked and accessible for both unit testing and development when servers were down. I'd highly recommend checking it out!
-
What are the new and exciting tech for React projects for 2022?
Feel free to check out the in-depth ReadMe, install, see the JSDoc, source code, or check out the React demo.
msw-storybook-addon
-
Storybook - mocking API calls
As mentioned, we'll be using the MSW addon, which stands for: "Mock Service Worker", it adds a service worker that will intercept and mock our requests.
-
How to structure React components so I can test them with Storybook?
If data is fetched through the API, https://github.com/itaditya/msw-storybook-addon
What are some alternatives?
axios-mock-adapter - Axios adapter that allows to easily mock requests
P2PoW - A P2P Delegated Proof of Work solution for Nano cryptocurrency
mocktail - Free, 11MB, containerized, self-hosted mock server.
msw - Seamless REST/GraphQL API mocking library for browser and Node.js.
LibreTrader - Open Source Trading Journal
examples - Examples of Mock Service Worker usage with various frameworks and libraries.
http-fake-backend - Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
frhd - An api wrapper for Free Rider HD.
open-api-mocker - A mock server based in OpenAPI Specification
jotai - 👻 Primitive and flexible state management for React
smoke - :dash: Simple yet powerful file-based mock server with recording abilities