Skip to content
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

Merged
merged 18 commits into from
Sep 9, 2024
Merged

Docs: Vitest plugin #28924

merged 18 commits into from
Sep 9, 2024

Conversation

kylegach
Copy link
Contributor

@kylegach kylegach commented Aug 20, 2024

What I did

Add docs for the Vitest plugin

Checklist for Contributors

Testing

Manual testing

Sync locally running docs with this branch

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/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.

  • Added docs/writing-tests/test-runner-with-vitest.mdx detailing installation, setup, and usage of the Vitest test runner
  • Updated docs/writing-tests/import-stories-in-tests/stories-in-unit-tests.mdx to include Vitest examples for unit testing with Storybook stories
  • Added docs/_snippets/addon-vitest-install.md and docs/_snippets/addon-vitest-run-tests.md with installation and test execution instructions
  • Modified docs/writing-tests/visual-testing.mdx to include information about the new Visual Tests addon
  • Adjusted sidebar ordering across multiple documentation files to accommodate the new Vitest content

@kylegach kylegach self-assigned this Aug 20, 2024
Copy link

nx-cloud bot commented Aug 20, 2024

☁️ Nx Cloud Report

CI 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 target

Sent with 💌 from NxCloud.

Copy link
Member

@yannbf yannbf left a 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 Show resolved Hide resolved
Comment on lines 32 to 55
<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>
Copy link
Member

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',
    },
  },
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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

docs/writing-tests/addon-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/addon-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/addon-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/addon-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/addon-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/addon-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/addon-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/addon-vitest.mdx Outdated Show resolved Hide resolved

{/* TODO: Snippetize */}
```sh
npx storybook@latest add @storybook/experimental-addon-vitest
Copy link
Contributor

@kasperpeulen kasperpeulen Aug 23, 2024

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
@kylegach kylegach changed the title WIP: Docs for Test runner with Vitest Docs: Test runner with Vitest Aug 26, 2024
@kylegach kylegach marked this pull request as ready for review August 26, 2024 18:35
@kylegach kylegach added the ci:docs Run the CI jobs for documentation checks only. label Aug 26, 2024
Copy link
Contributor

@greptile-apps greptile-apps bot left a 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>
Copy link
Contributor

@jonniebigodes jonniebigodes left a 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,

docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
* 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
* 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]
  ...
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
docs/writing-tests/test-runner-with-vitest.mdx Outdated Show resolved Hide resolved
kylegach and others added 3 commits September 6, 2024 10:13
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
  ...
@kylegach kylegach changed the title Docs: Test runner with Vitest Docs: Vitest plugin Sep 9, 2024
@kylegach kylegach merged commit dbf8ea1 into next Sep 9, 2024
9 checks passed
@kylegach kylegach deleted the docs-addon-vitest branch September 9, 2024 20:09
@github-actions github-actions bot mentioned this pull request Sep 9, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:docs Run the CI jobs for documentation checks only. documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants