how to test .mdx files indexed with stories? #32429
Replies: 4 comments 3 replies
-
Hi @PoornimaKaruppasamy! I'm Dosu and I’m helping the storybook team. You can test .mdx files indexed as stories in Storybook using the test-runner just like regular stories. The test-runner automatically renders all stories—including those from .mdx files—and will fail if there are rendering errors, such as missing imports in your documentation. To ensure .mdx files are tested, include them in your stories glob pattern (e.g., If you want stricter error detection, run the test-runner with the If you use Vite and addon-vitest, be aware that certain plugin setups can break MDX rendering in Storybook 9—splitting your Vite and Vitest configs is the recommended workaround. In summary: as long as your .mdx files are indexed, the test-runner will catch documentation errors at render time, and you can enhance this with console error checks and MDX linting tools. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
Storybook config: Still test-runner has not reported rendering error when there is missing import. For example: button.stories.ts turns into tests and it passes everytime, although the related mdx file button.mdx has missing import. It did not report any errors. |
Beta Was this translation helpful? Give feedback.
-
Is there a possibility to add 'tag' in the *.mdx file for the test runner to identify and test ? I have tags added in CSF stories. How to adjust test-runner config to include docs-only stories (includeDocsOnly option) in your test-runner? |
Beta Was this translation helpful? Give feedback.
-
--failOnConsole flag did not help to get runtime errors from .mdx file like missing imports |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I am using test-runner to test my stories. Storybook indexers identifies the related .mdx files. How to test the .mdx files? For example: If we delete an import needed in the documentation, it renders error.
Additional information
No response
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions