A Storybook addon that provides Jest-like module mocking for Vite-based Storybook projects (v10+). Version 1.1.1 is current, with active development on GitHub. It replaces module imports with mock implementations during Storybook stories, using a Vite plugin and a createMock function. Unlike traditional Jest mocks that require a test runner, this addon works directly in Storybook's preview environment, allowing visual testing of components with mocked dependencies. It supports @storybook/react-vite and @storybook/nextjs-vite frameworks. The mockRestore() is automatic after story unmount. Configuration via addon options allows include/exclude patterns for builds. Ships TypeScript types.
npm install storybook-addon-vite-mockVerified import paths — ran on the pinned version, not inferred.
Set up the addon in Storybook config and create a mock for a module import in a story.
Use a Vite-based framework like @storybook/react-vite or @storybook/nextjs-vite.
Remove viteFinal if you only need Storybook 10; add 'storybook-addon-vite-mock' to addons array.
Place createMock calls at top level of story file, not inside a component or effect.
Do not rely on include/exclude for filtering in dev mode; they are ignored.
Upgrade Storybook to version 9 or 10, or stay on storybook-addon-vite-mock@1.0.x.
Run `npm install --save-dev storybook-addon-vite-mock` and ensure tsconfig.json includes node_modules types.
Change to `import { createMock } from 'storybook-addon-vite-mock'`.Switch to a Vite-based framework like @storybook/react-vite.
No dependency data recorded yet.