docs/_snippets/msw-addon-initialize.md
import { initialize, mswLoader } from 'msw-storybook-addon';
/*
* Initializes MSW
* See https://github.com/mswjs/msw-storybook-addon#configuring-msw
* to learn how to customize it
*/
initialize();
export default {
loaders: [mswLoader], // ๐ Add the MSW loader to all stories
};
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc.
import type { Preview } from '@storybook/your-framework';
import { initialize, mswLoader } from 'msw-storybook-addon';
/*
* Initializes MSW
* See https://github.com/mswjs/msw-storybook-addon#configuring-msw
* to learn how to customize it
*/
initialize();
const preview: Preview = {
loaders: [mswLoader], // ๐ Add the MSW loader to all stories
};
export default preview;
// Replace your-framework with the framework you are using (e.g., react-vite, nextjs, nextjs-vite)
import { definePreview } from '@storybook/your-framework';
import { initialize, mswLoader } from 'msw-storybook-addon';
/*
* Initializes MSW
* See https://github.com/mswjs/msw-storybook-addon#configuring-msw
* to learn how to customize it
*/
initialize();
export default definePreview({
loaders: [mswLoader], // ๐ Add the MSW loader to all stories
});
// Replace your-framework with the framework you are using (e.g., react-vite, nextjs, nextjs-vite)
import { definePreview } from '@storybook/your-framework';
import { initialize, mswLoader } from 'msw-storybook-addon';
/*
* Initializes MSW
* See https://github.com/mswjs/msw-storybook-addon#configuring-msw
* to learn how to customize it
*/
initialize();
export default definePreview({
loaders: [mswLoader], // ๐ Add the MSW loader to all stories
});
import { definePreview } from '@storybook/vue3-vite';
import { initialize, mswLoader } from 'msw-storybook-addon';
/*
* Initializes MSW
* See https://github.com/mswjs/msw-storybook-addon#configuring-msw
* to learn how to customize it
*/
initialize();
export default definePreview({
loaders: [mswLoader], // ๐ Add the MSW loader to all stories
});
import { definePreview } from '@storybook/vue3-vite';
import { initialize, mswLoader } from 'msw-storybook-addon';
/*
* Initializes MSW
* See https://github.com/mswjs/msw-storybook-addon#configuring-msw
* to learn how to customize it
*/
initialize();
export default definePreview({
loaders: [mswLoader], // ๐ Add the MSW loader to all stories
});
import { definePreview } from '@storybook/angular';
import { initialize, mswLoader } from 'msw-storybook-addon';
/*
* Initializes MSW
* See https://github.com/mswjs/msw-storybook-addon#configuring-msw
* to learn how to customize it
*/
initialize();
export default definePreview({
loaders: [mswLoader], // ๐ Add the MSW loader to all stories
});
import { definePreview } from '@storybook/web-components-vite';
import { initialize, mswLoader } from 'msw-storybook-addon';
/*
* Initializes MSW
* See https://github.com/mswjs/msw-storybook-addon#configuring-msw
* to learn how to customize it
*/
initialize();
export default definePreview({
loaders: [mswLoader], // ๐ Add the MSW loader to all stories
});
import { definePreview } from '@storybook/web-components-vite';
import { initialize, mswLoader } from 'msw-storybook-addon';
/*
* Initializes MSW
* See https://github.com/mswjs/msw-storybook-addon#configuring-msw
* to learn how to customize it
*/
initialize();
export default definePreview({
loaders: [mswLoader], // ๐ Add the MSW loader to all stories
});