docs/_snippets/automock-register-spy.md
// Replace your-framework with the framework you are using (e.g., react-vite, nextjs, vue3-vite, sveltekit)
import type { Preview } from '@storybook/your-framework';
import { sb } from 'storybook/test';
// ๐ Automatically spies on all exports from the `lib/session` local module
sb.mock(import('../lib/session.ts'), { spy: true });
// ๐ Automatically spies on all exports from the `uuid` package in `node_modules`
sb.mock(import('uuid'), { spy: true });
const preview: Preview = {
// ...
};
export default preview;
import { sb } from 'storybook/test';
// ๐ Automatically spies on all exports from the `lib/session` local module
sb.mock('../lib/session.js', { spy: true });
// ๐ Automatically spies on all exports from the `uuid` package in `node_modules`
sb.mock('uuid', { spy: true });
export default {
// ...
};
// Replace your-framework with the framework you are using (e.g., react-vite, nextjs, nextjs-vite)
import { definePreview } from '@storybook/your-framework';
import { sb } from 'storybook/test';
// ๐ Automatically spies on all exports from the `lib/session` local module
sb.mock(import('../lib/session.ts'), { spy: true });
// ๐ Automatically spies on all exports from the `uuid` package in `node_modules`
sb.mock(import('uuid'), { spy: true });
export default definePreview({
// ...
});
// Replace your-framework with the framework you are using (e.g., react-vite, nextjs, nextjs-vite)
import { definePreview } from '@storybook/your-framework';
import { sb } from 'storybook/test';
// ๐ Automatically spies on all exports from the `lib/session` local module
sb.mock('../lib/session.js', { spy: true });
// ๐ Automatically spies on all exports from the `uuid` package in `node_modules`
sb.mock('uuid', { spy: true });
export default definePreview({
// ...
});
import { definePreview } from '@storybook/vue3-vite';
import { sb } from 'storybook/test';
// ๐ Automatically spies on all exports from the `lib/session` local module
sb.mock(import('../lib/session.ts'), { spy: true });
// ๐ Automatically spies on all exports from the `uuid` package in `node_modules`
sb.mock(import('uuid'), { spy: true });
export default definePreview({
// ...
});
import { definePreview } from '@storybook/vue3-vite';
import { sb } from 'storybook/test';
// ๐ Automatically spies on all exports from the `lib/session` local module
sb.mock('../lib/session.js', { spy: true });
// ๐ Automatically spies on all exports from the `uuid` package in `node_modules`
sb.mock('uuid', { spy: true });
export default definePreview({
// ...
});
import { definePreview } from '@storybook/angular';
import { sb } from 'storybook/test';
// ๐ Automatically spies on all exports from the `lib/session` local module
sb.mock(import('../lib/session.ts'), { spy: true });
// ๐ Automatically spies on all exports from the `uuid` package in `node_modules`
sb.mock(import('uuid'), { spy: true });
export default definePreview({
// ...
});
import { definePreview } from '@storybook/web-components-vite';
import { sb } from 'storybook/test';
// ๐ Automatically spies on all exports from the `lib/session` local module
sb.mock(import('../lib/session.ts'), { spy: true });
// ๐ Automatically spies on all exports from the `uuid` package in `node_modules`
sb.mock(import('uuid'), { spy: true });
export default definePreview({
// ...
});
import { definePreview } from '@storybook/web-components-vite';
import { sb } from 'storybook/test';
// ๐ Automatically spies on all exports from the `lib/session` local module
sb.mock('../lib/session.js', { spy: true });
// ๐ Automatically spies on all exports from the `uuid` package in `node_modules`
sb.mock('uuid', { spy: true });
export default definePreview({
// ...
});