The `storybook_vitest_addon` integrates Vitest unit test results directly into a Storybook panel, enhancing the development workflow by displaying relevant test outcomes alongside component stories. This addon is currently at version `0.1.8` and has a relatively frequent release cadence, often aligning with Storybook and Vitest major version updates, as seen with recent upgrades to Storybook 8. It primarily supports React and Vite-based Storybook setups, requiring `vitest` v1.1.0 or newer. Its key differentiator is its minimal visual overhead, focusing on clarity for test results, and its direct integration via Storybook parameters, making it straightforward to link test output (JSON format) to individual stories. Developers provide a JSON file of Vitest results and the test file name to the addon's parameters to enable the display.
npm install storybook_vitest_addonVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to configure the `storybook_vitest_addon` in a Storybook story file, linking Vitest test results to a component.
Always check the `Compatibility` section in the addon's README or `package.json` for supported Storybook and Vitest versions when upgrading either dependency. For Storybook 8, ensure `storybook_vitest_addon` is `v0.1.7` or newer.
Upgrade to `storybook_vitest_addon` `v0.0.6` or newer if using Vitest `v0.8.0` or higher to ensure correct parsing of test results.
Configure your `vitest` script to output results to a JSON file (e.g., `vitest run --json --outputFile=./unit-test-results.json`). Then, import this file into your Storybook stories.
Ensure `testFile` and `testResults` parameters are correctly set within `parameters.vitest` for the story. Verify that the `unit-test-results.json` file actually contains valid Vitest output and is being correctly imported.
Run `npm install storybook_vitest_addon` or `yarn add storybook_vitest_addon`. Ensure the package is listed in `devDependencies` in `package.json`.
Add `storybook_vitest_addon` to your `.storybook/main.js` or `.storybook/main.ts` `addons` array. Ensure your story's `parameters` object has a `vitest` key with `testFile` and `testResults`.
Update `storybook_vitest_addon` to the latest compatible version. For Storybook 8, this typically means `storybook_vitest_addon@0.1.7` or higher.