https://github.com/debuggercrafts/storybook-mock-api
Setup fetch mocks using fetch-mock
https://github.com/debuggercrafts/storybook-mock-api
fetch javascript reactjs storybook storybook-addon
Last synced: about 1 month ago
JSON representation
Setup fetch mocks using fetch-mock
- Host: GitHub
- URL: https://github.com/debuggercrafts/storybook-mock-api
- Owner: debuggercrafts
- Created: 2019-02-03T12:52:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-08-14T06:31:53.000Z (almost 3 years ago)
- Last Synced: 2025-01-23T09:45:02.864Z (4 months ago)
- Topics: fetch, javascript, reactjs, storybook, storybook-addon
- Language: JavaScript
- Homepage:
- Size: 238 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Storybook Mock fetch calls [](https://travis-ci.org/debuggercrafts/storybook-mock-api)
Mock fetch calls using [mockFetch](http://www.wheresrhys.co.uk/fetch-mock/#api-mockingmock) api.
## Usage
1. Add decorator to [configure mockFetch](http://www.wheresrhys.co.uk/fetch-mock/#usageconfiguration) library.
2. Setup mocks with [mockFetch api](http://www.wheresrhys.co.uk/fetch-mock/#api-mockingmock).```js
import mockFetch from '../../src/index'...
storiesOf('About mocking api calls')
.addDecorator(
// Configure mockFetch
mockFetch({
fallbackToNetwork: true,
sendAsJson: true,
overwriteRoutes: false,
})
)
.add('Fetch ',
() => Fetch the call,
{
mockFetch: mockFetch => {
// Setup mock fetch
mockFetch.get('/api/apples', {
status: 200,
body: [1, 3, 4],
})
},
}
)
```