Link Search Menu Expand Document

Sometimes you may have a React component in your storybook that make calls to a backend API, and will not function properly if that API is unreachable.

Just as we mock backend API endpoints in unit tests for React components, we can do the same in React Storybook.

Using Axios

Other approaches

Here are some articles on how to do it in various ways:

Using storybook-addon-mock

Using msw (Mock Service Worker) addon:

Using MockResolver:

Using FetchMock: