Skip to content

Instantly share code, notes, and snippets.

@ahayes91
Last active September 26, 2021 11:12
Show Gist options
  • Save ahayes91/89f8d9cfc5a0c59ec3d99cfa8d670daa to your computer and use it in GitHub Desktop.
Save ahayes91/89f8d9cfc5a0c59ec3d99cfa8d670daa to your computer and use it in GitHub Desktop.
import { addDecorator } from '@storybook/react';
import { initializeWorker, mswDecorator } from 'msw-storybook-addon';
import getConfigForCurrentEnv from 'get-env-config';
import { getEnvironment } from 'get-environment';
import { userContextDecorator } from '../__mocks__/auth';
const { storyBook } = getConfigForCurrentEnv();
const env = getEnvironment();
// Only use Mock Service Worker when we are running locally for now
if (env === 'local' || env === 'development') {
initializeWorker({
serviceWorker: {
// Points to the custom location of the Service Worker file.
url: `${storyBook}mockServiceWorker.js`,
},
});
addDecorator(mswDecorator);
addDecorator(userContextDecorator);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment