Storybook 9.1 introduces a new module mocking system powered by sb.mock() that automatically mocks dependencies without requiring package.json changes or import path modifications. The system uses ahead-of-time transformation to rewrite dependency graphs before bundling, supporting both Vite and Webpack in development and production. It offers automocking, spying capabilities, __mocks__ directory support, and type-safe mocking with dynamic imports, providing a cleaner alternative to the previous subpath imports approach.
Table of contents
Introducing sb.mock()How to Use ItHow It Works: Ahead-of-Time TransformationTry It TodaySort: