-
-
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: Vitest plugin #28924
Docs: Vitest plugin #28924
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit de82bf0. 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. |
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.
Good stuff! I hope @shilman can take a look soon once the PR is ready for review!
docs/writing-tests/addon-vitest.mdx
Outdated
<If renderer="vue"> | ||
<Callout variant="info"> | ||
If your stories use template-based Vue components, you may need to [alias the `vue` module](https://vuejs.org/guide/scaling-up/tooling#note-on-in-browser-template-compilation) to resolve correctly in the Playwright CT environment. You can do this via the [`ctViteConfig` property](https://playwright.dev/docs/test-components#i-have-a-project-that-already-uses-vite-can-i-reuse-the-config): | ||
|
||
<details> | ||
<summary>Example Playwright configuration</summary> | ||
|
||
```ts | ||
// playwright-config.ts | ||
import { defineConfig } from '@playwright/experimental-ct-vue'; | ||
|
||
export default defineConfig({ | ||
ctViteConfig: { | ||
resolve: { | ||
alias: { | ||
vue: 'vue/dist/vue.esm-bundler.js', | ||
}, | ||
}, | ||
}, | ||
}); | ||
``` | ||
</details> | ||
</Callout> | ||
</If> |
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 should be related to Vite instead of Playwright
export default defineConfig({
// ...
resolve: {
alias: {
vue: 'vue/dist/vue.esm-bundler.js',
},
},
})
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.
Does this also apply to https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest?renderer=vue ?
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.
@kylegach yes we could actually provide that as a solution for direct PS users too! Perhaps for PS in Playwright CT as well, via use.ctViteConfig.plugins
|
||
{/* TODO: Snippetize */} | ||
```sh | ||
npx storybook@latest add @storybook/experimental-addon-vitest |
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.
Didn't we had an agreement that npx storybook [command]
is better for most command except upgrade and init? cc @shilman @valentinpalkovic have maybe more context here.
- Includes sidebar order updates - Use non-zero-indexed orders
a094111
to
431d8fe
Compare
431d8fe
to
8cdbbaf
Compare
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.
LGTM
16 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
* next: Address feedback Address comments Typo Further updates Address feedback Remove TK Futher updates to #28716
Co-authored-by: Kasper Peulen <kasperpeulen@gmail.com>
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.
Just did a first pass at this and left some feedback for you to look into when you can. Let me know and we'll go from there,
* next: (33 commits) fix lint Clarify requirements of Next.js with Vite Next.js-Vite: Update next and vite-plugin-storybook-nextjs dependencies Addon Vitest: Fix tests potentially not existing in non-isolate mode CLI: Update spawn options in proxy.ts to support Windows Builder-Vite: Fix 'condition node never be used' warning Bump version from "8.3.0-alpha.9" to "8.3.0-alpha.10" [skip ci] Write changelog for 8.3.0-alpha.10 [skip ci] make prettier a normal dependency of core again. restore formatter code Use relative path from workspace to vite.config in extends path CLI: Fix dedent import in package managers Support JSX file extensions as well Addon Vitest: Fix postinstall file types Remove (disable) isolate option because it sometimes doesn't show stories add TODO comment make prettier optional improve meta file generation patch babel traverse types to be compatible with our dts bundler minimize changes minimize changes ...
* next: Address feedback add link to docs for how to set feature flags. improve migration notes for globals project Fix typo ConfigFile: Fix `as const satisfies` modifiers Bump version from "8.3.0-alpha.11" to "8.3.0-beta.0" [skip ci] Update docs/versions/next.json Add description to empty 8.3.0-beta.0 release Write changelog for 8.3.0-beta.0 [skip ci] Bump version from "8.3.0-alpha.10" to "8.3.0-alpha.11" [skip ci] Write changelog for 8.3.0-alpha.11 [skip ci] Re-order sidebar Rename interaction test -> component test
- Limit to react, vue, and svelte renderers - `addon-vitest` -> `addon-test` - `addon-vitest/plugin` -> `addon-test/vite-plugin` - Add requirements - Add more details and examples about framework plugins - Add more detail about test setup file - Move comparison to previous test runner into its own section - Format snippets
d795ced
to
59f926a
Compare
* next: (31 commits) add playwright eslint plugin, fix tests by rules fix tags e2e test fix urls in addon-test package.json use auto-retrying assertions in e2e tests renamed vitest addon import file name to 'test' Bump version from "8.3.0-beta.1" to "8.3.0-beta.2" [skip ci] Write changelog for 8.3.0-beta.2 [skip ci] fix package order in versions fix import fix add tests CLI: Handle Yarn PnP wrapper scenario when adding an addon cleanup Add type declaration for storybookTest in plugin module dont' use parameters for default backgrounds, as they are not overridable Fix type export for @storybook/experimental-nextjs-vite/vite-plugin don't use parameters for default viewports, as they are not overridable Nextjs-Vite: Re-export vite-plugin-storybook-nextjs refactor vite plugin export paths Bump version from "8.3.0-beta.0" to "8.3.0-beta.1" [skip ci] ...
Co-authored-by: Yann Braga <yannbf@gmail.com>
* next: (25 commits) Bump version from "8.3.0-beta.3" to "8.3.0-beta.4" [skip ci] Write changelog for 8.3.0-beta.4 [skip ci] rename vitest plugin entrypoint add narrow story to Sidebar upgrade @radix-ui/react-scroll-area Bump version from "8.3.0-beta.2" to "8.3.0-beta.3" [skip ci] Write changelog for 8.3.0-beta.3 [skip ci] fix lint only append addon to main.js if not already added final fixes Next.js: Update dependencies only install the necessary dependencies Next.js-Vite: Fix vite plugin exports use named import from dedent review improvements add explanation in sb add command add helpful links additional fixes Consistently naming the 'Storybook Test' addon CONSTANT_CASE for constants ...
What I did
Add docs for the Vitest plugin
Checklist for Contributors
Testing
Manual testing
Sync locally running docs with this branch
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 introduces documentation for the new experimental Test runner with Vitest addon for Storybook, along with updates to existing testing documentation.
docs/writing-tests/test-runner-with-vitest.mdx
detailing installation, setup, and usage of the Vitest test runnerdocs/writing-tests/import-stories-in-tests/stories-in-unit-tests.mdx
to include Vitest examples for unit testing with Storybook storiesdocs/_snippets/addon-vitest-install.md
anddocs/_snippets/addon-vitest-run-tests.md
with installation and test execution instructionsdocs/writing-tests/visual-testing.mdx
to include information about the new Visual Tests addon