Bring 'magical' Vitest style module mocking to storybook #30780
centraldogma99
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is your feature request related to a problem? Please describe.
Currently, Storybook suggests implementing module mocking through subpath imports. While subpath imports are excellent in many ways, they do have some inconveniences. Specifically, even if you only need to mock a file in a single test code, you still need to create a .mock.ts file and add several lines to your package.json.
Describe the solution you'd like
In Vitest, you can mock modules as follows:
This approach has the advantage of allowing you to work only in the files where mocking is needed, without having to create .mock.ts files or modify your package.json.
After reviewing the related RFC document, I've noticed that "magical" mocking approaches similar to Vitest are currently excluded from the support plans.
I have a few questions regarding this:
Are there any plans to support automated mocking approaches similar to Vitest in the future? Is there any work currently in progress on this front?
If not, I'd like to contribute to developing this feature. Since Storybook's codebase is quite complex, I'm finding it challenging to determine where to begin. Could you recommend any documentation or resources that would help me understand the code or architecture related to the module mocking system?
Are there any specific design principles or guidelines I should consider when contributing to such a feature development?
Describe alternatives you've considered
No response
Are you able to assist to bring the feature to reality?
yes, I can
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions