---
title: "Next-generation module mocking in Storybook"
url: https://daily.dev/posts/next-generation-module-mocking-in-storybook-ab9gphmxo
source_url: https://storybook.js.org/blog/next-generation-module-mocking/
type: article
source: "Storybook"
published: 2025-08-21T18:02:20.384Z
updated: 2025-08-21T18:02:50.867Z
tags: ["testing", "typescript", "storybook", "vitest"]
reading_time: 6
upvotes: 5
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Next-generation module mocking in Storybook

**[Storybook](https://daily.dev/sources/storybook)** · 6 min read · 5 upvotes · 0 comments

## Summary

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.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://storybook.js.org/blog/next-generation-module-mocking/>

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 0 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#typescript](https://daily.dev/tags/typescript), [#storybook](https://daily.dev/tags/storybook), [#vitest](https://daily.dev/tags/vitest)

[View this post on daily.dev](https://daily.dev/posts/next-generation-module-mocking-in-storybook-ab9gphmxo)
