Skip to content

Commit 38d9dec

Browse files
authored
Merge pull request #33061 from storybookjs/docs-test-runner-migration
Docs: Add migration guide for test-runner -> Vitest addon
2 parents fe334bf + 74a4036 commit 38d9dec

20 files changed

+232
-96
lines changed

docs/api/csf/csf-next.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ All of the story properties are now contained within a new property called `comp
404404

405405
**4. Update your Vitest setup file**
406406

407-
If you're using [Storybook's Vitest addon](../../writing-tests/integrations/vitest-addon.mdx), you can remove your Vitest setup file (`.storybook/vitest.setup.ts`).
407+
If you're using [Storybook's Vitest addon](../../writing-tests/integrations/vitest-addon/index.mdx), you can remove your Vitest setup file (`.storybook/vitest.setup.ts`).
408408

409409
If you are using [portable stories in Vitest](../portable-stories/portable-stories-vitest.mdx), you may use a Vitest setup file to configure your stories. This file must be updated to use the new CSF Next format.
410410

@@ -431,7 +431,7 @@ import { setProjectAnnotations } from '@storybook/your-framework';
431431

432432
**5. Reusing stories in test files**
433433

434-
[Storybook's Vitest addon](../../writing-tests/integrations/vitest-addon.mdx) allows you to test your components directly inside Storybook. All the stories are automatically turned into Vitest tests, making integration seamless in your testing suite.
434+
[Storybook's Vitest addon](../../writing-tests/integrations/vitest-addon/index.mdx) allows you to test your components directly inside Storybook. All the stories are automatically turned into Vitest tests, making integration seamless in your testing suite.
435435

436436
If you cannot use Storybook Test, you can still reuse the stories in your test files using [portable stories](../portable-stories/portable-stories-vitest.mdx). In prior story formats, you had to compose the stories before rendering them in your test files. With CSF Next, you can now reuse the stories directly.
437437

docs/api/portable-stories/portable-stories-vitest.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ sidebar:
2727

2828
<If renderer={['react', 'vue', 'svelte']}>
2929
<Callout variant="warning">
30-
Storybook now recommends testing your stories in Vitest with the [Vitest addon](../../writing-tests/integrations/vitest-addon.mdx), which automatically transforms stories into real Vitest tests (using this API under the hood).
30+
Storybook now recommends testing your stories in Vitest with the [Vitest addon](../../writing-tests/integrations/vitest-addon/index.mdx), which automatically transforms stories into real Vitest tests (using this API under the hood).
3131

3232
This API is still available for those who prefer to use portable stories directly, but we recommend using the Vitest addon for a more streamlined testing experience.
3333
</Callout>

docs/configure/telemetry.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Specifically, we track the following information in our telemetry events:
4242
* Testing tools (e.g. [Jest](https://jestjs.io/), [Vitest](https://vitest.dev/), [Playwright](https://playwright.dev/)).
4343
* Package manager information (e.g., `npm`, `yarn`).
4444
* Monorepo information (e.g., [NX](https://nx.dev/), [Turborepo](https://turborepo.org/)).
45-
* In-app events (e.g., [Storybook guided tour](https://github.com/storybookjs/addon-onboarding), [UI test run](../writing-tests/integrations/vitest-addon.mdx#storybook-ui)).
45+
* In-app events (e.g., [Storybook guided tour](https://github.com/storybookjs/addon-onboarding), [UI test run](../writing-tests/integrations/vitest-addon/index.mdx#storybook-ui)).
4646

4747
Access to the raw data is highly controlled, limited to select members of Storybook's core team who maintain the telemetry. We cannot identify individual users from the dataset: it is anonymized and untraceable back to the user.
4848

docs/get-started/frameworks/nextjs-vite.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This Vite-based framework offers several advantages over the Webpack-based [`@st
1919

2020
***Faster builds** - Vite's build system is significantly faster than Webpack
2121
* 🔧 **Modern tooling** - Uses the latest build tools and optimizations
22-
* 🧪 **Better test support** - Full support for the [Vitest addon](../../writing-tests/integrations/vitest-addon.mdx) and other testing features
22+
* 🧪 **Better test support** - Full support for the [Vitest addon](../../writing-tests/integrations/vitest-addon/index.mdx) and other testing features
2323
* 📦 **Simpler configuration** - No need for Babel or complex Webpack configurations
2424
* 🎯 **Better development experience** - Faster HMR (Hot Module Replacement) and dev server startup
2525

@@ -792,7 +792,7 @@ You can refer to the [Install `sharp` to Use Built-In Image Optimization](https:
792792
We recommend using `@storybook/nextjs-vite` (this framework) for most projects because it offers:
793793

794794
* Faster builds and development server startup
795-
* Better support for modern testing features like the [Vitest addon](../../writing-tests/integrations/vitest-addon.mdx)
795+
* Better support for modern testing features like the [Vitest addon](../../writing-tests/integrations/vitest-addon/index.mdx)
796796
* Simpler configuration without Babel
797797
* Better developer experience with faster HMR
798798

docs/get-started/install.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ If you're experienced with Storybook, you can skip the onboarding to get a minim
103103

104104
Storybook will ask what type of configuration you want to install:
105105

106-
* **Recommended**: Includes component development, [documentation](../writing-docs/autodocs.mdx), [testing](../writing-tests/integrations/vitest-addon.mdx), and [accessibility](../writing-tests/accessibility-testing.mdx) features
106+
* **Recommended**: Includes component development, [documentation](../writing-docs/autodocs.mdx), [testing](../writing-tests/integrations/vitest-addon/index.mdx), and [accessibility](../writing-tests/accessibility-testing.mdx) features
107107
* **Minimal**: Just the essentials for component development
108108

109109
You can also manually select these features using the `--features` flag. For example:

docs/releases/migration-guide-from-older-version.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ In addition to the automigrations and manual migrations above, there are also op
157157

158158
### `test-runner` to `addon-vitest`
159159

160-
`addon-vitest` and the rest of the [Storybook Test experience](https://storybook.js.org/blog/storybook-test-sneak-peek/) is designed to supercede the `test-runner`. It's faster and provides a better experience for writing and running tests. If your project uses React, Vue, or Svelte and is built with Vite, you should consider migrating to `addon-vitest`, by following the [installation instructions](../writing-tests/integrations/vitest-addon.mdx#automatic-setup).
160+
`addon-vitest` and the rest of the [Storybook Test experience](https://storybook.js.org/blog/storybook-test-sneak-peek/) is designed to supercede the `test-runner`. It's faster and provides a better experience for writing and running tests. If your project uses React, Vue, or Svelte and is built with Vite, you should consider migrating to `addon-vitest`, by following the [installation instructions](../writing-tests/integrations/vitest-addon/index.mdx#automatic-setup).
161161

162162
### CSF 2 to CSF 3
163163

docs/releases/migration-guide.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ In addition to the automigrations and manual migrations above, there are also op
9797

9898
### `test-runner` to `addon-vitest`
9999

100-
`addon-vitest` and the rest of the [Storybook Test experience](https://storybook.js.org/blog/storybook-test-sneak-peek/) is designed to supercede the `test-runner`. It's faster and provides a better experience for writing and running tests. If your project uses React, Vue, or Svelte and is built with Vite, you should consider migrating to `addon-vitest`, by following the [installation instructions](../writing-tests/integrations/vitest-addon.mdx#automatic-setup).
100+
`addon-vitest` and the rest of the [Storybook Test experience](https://storybook.js.org/blog/storybook-test-sneak-peek/) is designed to supercede the `test-runner`. It's faster and provides a better experience for writing and running tests. If your project uses React, Vue, or Svelte and is built with Vite, you should consider migrating to `addon-vitest`, by following the [installation instructions](../writing-tests/integrations/vitest-addon/index.mdx#automatic-setup).

docs/writing-stories/tags.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The following tags are available in every Storybook project:
1414
| Tag | Applied by default? | Description |
1515
| ---------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1616
| `dev` | Yes | Stories tagged with `dev` are rendered in Storybook's sidebar. |
17-
| `test` | Yes | Stories tagged with `test` are included in [test runner](../writing-tests/integrations/test-runner.mdx#run-tests-for-a-subset-of-stories) or [Vitest addon](../writing-tests/integrations/vitest-addon.mdx#including-excluding-or-skipping-tests) runs. |
17+
| `test` | Yes | Stories tagged with `test` are included in [test runner](../writing-tests/integrations/test-runner.mdx#run-tests-for-a-subset-of-stories) or [Vitest addon](../writing-tests/integrations/vitest-addon/index.mdx#including-excluding-or-skipping-tests) runs. |
1818
| `autodocs` | No | Stories tagged with `autodocs` are included in the [docs page](../writing-docs/autodocs.mdx). If a CSF file does not contain at least one story tagged with `autodocs`, that component will not generate a docs page. |
1919
| `play-fn` | No | Applied automatically to stories with a [play function](./play-function.mdx) defined. |
2020
| `test-fn` | No | Applied automatically to tests defined using the [experimental `.test` method on CSF Factories](https://github.com/storybookjs/storybook/discussions/30119). |

docs/writing-tests/accessibility-testing.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Your Storybook will now include some features to check the accessibility of your
3535

3636
### Integration with Vitest addon
3737

38-
The accessibility addon is designed to integrate with the [Vitest addon](./integrations/vitest-addon.mdx), so that you can [run accessibility tests](#run-accessibility-tests) alongside your component tests.
38+
The accessibility addon is designed to integrate with the [Vitest addon](./integrations/vitest-addon/index.mdx), so that you can [run accessibility tests](#run-accessibility-tests) alongside your component tests.
3939

4040
**Automatic configuration:**
4141

@@ -147,7 +147,7 @@ You can also enable, disable, or configure individual rules. This can be done in
147147

148148
### Test behavior
149149

150-
You can configure accessibility tests with the `parameters.a11y.test` [parameter](../writing-stories/parameters.mdx), which determines the behavior of accessibility tests for a story when run with either the [Vitest addon](./integrations/vitest-addon.mdx) or the [test-runner](./integrations/test-runner.mdx). The parameter accepts three values:
150+
You can configure accessibility tests with the `parameters.a11y.test` [parameter](../writing-stories/parameters.mdx), which determines the behavior of accessibility tests for a story when run with either the [Vitest addon](./integrations/vitest-addon/index.mdx) or the [test-runner](./integrations/test-runner.mdx). The parameter accepts three values:
151151

152152
| Value | Description |
153153
| --------- | ---------------------------------------------------------------------------------------- |
@@ -197,10 +197,10 @@ When you disable automated accessibility checks, the addon will not run any test
197197

198198
### With the Vitest addon
199199

200-
If you're using the [Vitest addon](./integrations/vitest-addon.mdx), you can run your accessibility tests, as part of component tests, in these ways:
200+
If you're using the [Vitest addon](./integrations/vitest-addon/index.mdx), you can run your accessibility tests, as part of component tests, in these ways:
201201

202-
- [In the Storybook UI](./integrations/vitest-addon.mdx#storybook-ui)
203-
- [In CI environments](./integrations/vitest-addon.mdx#in-ci)
202+
- [In the Storybook UI](./integrations/vitest-addon/index.mdx#storybook-ui)
203+
- [In CI environments](./integrations/vitest-addon/index.mdx#in-ci)
204204

205205
To run accessibility tests in the Storybook UI, first expand the testing widget in the sidebar and check the Accessibility checkbox. Now, when you press the Run component tests button, the accessibility tests will be run along with any other tests you have configured.
206206

@@ -267,7 +267,7 @@ Browser-based accessibility tests, like those found in Storybook, evaluate the r
267267

268268
### Why are my tests failing in different environments?
269269

270-
With the [Vitest addon](./integrations/vitest-addon.mdx), your tests run in Vitest using your project's configuration with Playwright's Chromium browser. This can lead to inconsistent test results reported in the Storybook UI or CLI. The inconsistency can be due to `axe-core` reporting different results in different environments, such as browser versions or configurations. If you encounter this issue, we recommend reaching out using the default communication channels (e.g., [GitHub discussions](https://github.com/storybookjs/storybook/discussions/new?category=help), [Github issues](https://github.com/storybookjs/storybook/issues/new?template=bug_report.yml)).
270+
With the [Vitest addon](./integrations/vitest-addon/index.mdx), your tests run in Vitest using your project's configuration with Playwright's Chromium browser. This can lead to inconsistent test results reported in the Storybook UI or CLI. The inconsistency can be due to `axe-core` reporting different results in different environments, such as browser versions or configurations. If you encounter this issue, we recommend reaching out using the default communication channels (e.g., [GitHub discussions](https://github.com/storybookjs/storybook/discussions/new?category=help), [Github issues](https://github.com/storybookjs/storybook/issues/new?template=bug_report.yml)).
271271

272272
### The addon panel does not show expected violations
273273

@@ -281,7 +281,7 @@ To enable this feature flag, add the following configuration to your `.storybook
281281

282282
**More testing resources**
283283

284-
* [Vitest addon](./integrations/vitest-addon.mdx) for running tests in Storybook
284+
* [Vitest addon](./integrations/vitest-addon/index.mdx) for running tests in Storybook
285285
* [Interaction testing](./interaction-testing.mdx) for user behavior simulation
286286
* [Visual testing](./visual-testing.mdx) for appearance
287287
* [Snapshot testing](./snapshot-testing.mdx) for rendering errors and warnings

docs/writing-tests/in-ci.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar:
66
title: In CI
77
---
88

9-
The [Vitest addon](./integrations/vitest-addon.mdx) is great for automating your UI tests within Storybook. To have full confidence in your work, backed by tests, you need to run those automated tests in your continuous integration (CI) environment.
9+
The [Vitest addon](./integrations/vitest-addon/index.mdx) is great for automating your UI tests within Storybook. To have full confidence in your work, backed by tests, you need to run those automated tests in your continuous integration (CI) environment.
1010

1111
Thankfully, that’s quite easy!
1212

@@ -329,7 +329,7 @@ jobs:
329329
+ SB_URL: '${{ github.event.deployment_status.environment_url }}'
330330
```
331331

332-
Finally, we update the plugin configuration to use that environment variable in the [`storybookUrl` plugin option](./integrations/vitest-addon.mdx#storybookurl).
332+
Finally, we update the plugin configuration to use that environment variable in the [`storybookUrl` plugin option](./integrations/vitest-addon/index.mdx#storybookurl).
333333

334334
{/* prettier-ignore-start */}
335335

@@ -447,7 +447,7 @@ The workflow would then look like:
447447

448448
**More testing resources**
449449

450-
* [Vitest addon](./integrations/vitest-addon.mdx) for running tests in Storybook
450+
* [Vitest addon](./integrations/vitest-addon/index.mdx) for running tests in Storybook
451451
* [Interaction testing](./interaction-testing.mdx) for user behavior simulation
452452
* [Accessibility testing](./accessibility-testing.mdx) for accessibility
453453
* [Visual testing](./visual-testing.mdx) for appearance

0 commit comments

Comments
 (0)