-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Replace Vitest plugin with Test addon #29315
Conversation
#### Debugging | ||
|
||
While the plugin does not require Storybook to run when testing, you may still want to run Storybook to debug your tests. To enable this, provide the [`storybookScript` option](#storybookscript) in the plugin configuration. When you run Vitest in watch mode, the plugin will start Storybook using this script and provide links to the story in the output on test failures. This allows you to quickly jump to the story in Storybook to debug the issue. | ||
|
||
You can also provide a [`storybookUrl` option](#storybookurl) to the plugin configuration. When you're not using watch mode and tests fail, the plugin will provide a link to the story using this URL in the output. This is useful when [running tests in CI](#in-ci) or other environments where Storybook is not already running. | ||
|
||
![Screenshot of test failure in the console, showing a failure with a link to the story](../_assets/writing-tests/vitest-plugin-test-failure.png) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same content as the previous debugging section that was immediately under Usage. I moved it to be under CLI because the page now presents the SB UI usage as primary and this section only pertains to CLI.
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 15c9433. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
docs/writing-tests/test-addon.mdx
Outdated
### What happens if Vitest itself has an error? | ||
|
||
Sometimes tests can fail because of errors within Vitest itself. When this happens, the test module in the Storybook UI will alert you to the error, and you can click a link to see more details. The error will also be logged to the console. | ||
|
||
{/* TODO: screenshot of test module with Vitest error */} | ||
|
||
Vitest offers [troubleshooting help for common errors](https://vitest.dev/guide/common-errors.html). | ||
|
||
### What happens when there are different test results in multiple environments? | ||
|
||
When you run tests with this addon, they are run as Vitest tests with whatever configuration you have set up in your project. By default, they will run in browser mode, using Playwright's Chromium browser. Sometimes, tests will fail when run in the addon (or via CLI), but then pass when viewed in the Component tests addon panel (or vice-versa). This can happen because the tests are run in different environments, which can have different behaviors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghengeveld @valentinpalkovic @yannbf — Is there more help we can offer for either of these sections?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is shaping up nicely, I left some items to be looked into when possible so that we can get this one and published
After running your tests, you will now see status indicators on stories and components for their pass, fail, or error state. You can press on these indicators to see more details and jump straight to the failure in the Component tests addon panel. That panel provides an interactive debugger for your component test, allowing you to step through each simulated behavior or assertion. | ||
|
||
<Callout variant="info" icon="ℹ️"> | ||
|
||
The Component tests addon panel replaces the [Interactions addon panel](../essentials/interactions.mdx) when the Test addon is installed. While the testing mechanism is different, the functionality of the addon panel itself remains the same. | ||
|
||
</Callout> | ||
|
||
The test module will also show you the total number of tests run, the number of tests that passed, and the number of tests that failed or errored. You can press the failure number to filter the sidebar to only those stories that failed. | ||
|
||
<Video src="../_assets/writing-tests/addon-test-filter-sidebar.mp4" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should be reframed and included inside a section on previewing the test results to educate the user on how to do it. There's a lot of information for the user to digest, which can result in confusion. The bonus is that we can use said section in the future for other learning materials, blogs, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree. The section first describes how to run tests and then how to review them. One must come after the other. Splitting that into two sub-sections would be overhead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to go ahead and merge this into the parent PR so that it goes out with the actual feature.
If you really feel strongly about this feedback (or anything else), please ping me in a comment over there.
Co-authored-by: Yann Braga <[email protected]>
Co-authored-by: Michael Shilman <[email protected]>
a97f63a
to
15c9433
Compare
(Part of #29088)
What I did
/docs/writing-tests/vitest-plugin
with/docs/writing-tests/test-addon
Checklist for Contributors
Manual testing
addon-test-docs
web
reponpm run sync-docs
npm run dev
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.Greptile Summary
This pull request replaces the Vitest plugin documentation with the new Test addon documentation, providing a comprehensive guide for using the Test addon in Storybook.
docs/writing-tests/vitest-plugin.mdx
todocs/writing-tests/test-addon.mdx
docs/_snippets/vitest-plugin-vitest-workspace.md
with renderer-specific configurations