2021-11-03 12:41:59 +02:00
|
|
|
import '../app/assets/css';
|
|
|
|
|
2021-12-14 21:14:53 +02:00
|
|
|
import { pushStateLocationPlugin, UIRouter } from '@uirouter/react';
|
2022-01-05 18:28:56 +02:00
|
|
|
import { initialize as initMSW, mswDecorator } from 'msw-storybook-addon';
|
|
|
|
import { handlers } from '@/setup-tests/server-handlers';
|
|
|
|
|
|
|
|
// Initialize MSW
|
|
|
|
initMSW({
|
|
|
|
onUnhandledRequest: ({ method, url }) => {
|
|
|
|
if (url.pathname.startsWith('/api')) {
|
|
|
|
console.error(`Unhandled ${method} request to ${url}.
|
|
|
|
|
|
|
|
This exception has been only logged in the console, however, it's strongly recommended to resolve this error as you don't want unmocked data in Storybook stories.
|
|
|
|
|
|
|
|
If you wish to mock an error response, please refer to this guide: https://mswjs.io/docs/recipes/mocking-error-responses
|
|
|
|
`);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
2021-12-14 21:14:53 +02:00
|
|
|
|
2021-11-03 12:41:59 +02:00
|
|
|
export const parameters = {
|
|
|
|
actions: { argTypesRegex: '^on[A-Z].*' },
|
|
|
|
controls: {
|
|
|
|
matchers: {
|
|
|
|
color: /(background|color)$/i,
|
|
|
|
date: /Date$/,
|
|
|
|
},
|
|
|
|
},
|
2022-01-05 18:28:56 +02:00
|
|
|
msw: {
|
|
|
|
handlers,
|
|
|
|
},
|
2021-11-03 12:41:59 +02:00
|
|
|
};
|
2021-12-14 21:14:53 +02:00
|
|
|
|
|
|
|
export const decorators = [
|
|
|
|
(Story) => (
|
|
|
|
<UIRouter plugins={[pushStateLocationPlugin]}>
|
|
|
|
<Story />
|
|
|
|
</UIRouter>
|
|
|
|
),
|
2022-01-05 18:28:56 +02:00
|
|
|
mswDecorator,
|
2021-12-14 21:14:53 +02:00
|
|
|
];
|