@debuggercrafts/storybook-addon-mock-api
v1.1.0
Published
mocking api calls in storybook
Downloads
9
Readme
Storybook Mock fetch calls
Mock fetch calls using mockFetch api.
Usage
- Add decorator to configure mockFetch library.
- Setup mocks with mockFetch api.
import mockFetch from '../../src/index'
...
storiesOf('About mocking api calls')
.addDecorator(
// Configure mockFetch
mockFetch({
fallbackToNetwork: true,
sendAsJson: true,
overwriteRoutes: false,
})
)
.add('Fetch ',
() => <button onClick={fetch('api/apples')}>Fetch the call</button>,
{
mockFetch: mockFetch => {
// Setup mock fetch
mockFetch.get('/api/apples', {
status: 200,
body: [1, 3, 4],
})
},
}
)