-
-
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
Addon Vitest: Add experimental vitest integration #28768
Merged
Merged
Changes from 191 commits
Commits
Show all changes
204 commits
Select commit
Hold shift + click to select a range
6e24da4
Replace experimental_SIDEBAR_BOTTOM API with a core story status filt…
ghengeveld dd5e342
Merge branch 'next' into sidebar-bottom-filters
yannbf 5a60cf5
Mark experimental_SIDEBAR_BOTTOM as deprecated
ghengeveld 61a0223
Update stories
ghengeveld 04bd79a
Mark experimental_SIDEBAR_TOP as deprecated
ghengeveld ed560db
Add migration notes for deprecated APIs
ghengeveld 257f53d
Rename story for consistency
ghengeveld 1964c2d
add Vitest integration tests to sandboxes
yannbf 67a6a60
disable most CI checks (revert this commit)
yannbf 8b309e4
skip html related sandboxes
yannbf eec554a
add svelte plugin
yannbf 834647d
fix sandbox filter
yannbf 8623b92
filter more sandboxes
yannbf d01d653
fix parallelization
yannbf ac1a81d
fix paths in sveltekit vitest config
yannbf f7f076c
add nextjs to vitest sandbox tests
yannbf ad09c0e
Update story status indicators and tooltips
ghengeveld 1cb605f
Update summary logic
ghengeveld c5b2538
Update icons and fix some stories
ghengeveld 7a7944a
Merge pull request #28693 from storybookjs/sidebar-bottom-filters
yannbf 9b35a31
Merge branch 'vitest-integration' into sidebar-story-status-tooltips
yannbf 84f5b63
Merge branch 'vitest-integration' into add-vitest-ci-task
yannbf abe32f6
set up nextjs
yannbf 80b5481
Fix success icon
ghengeveld b644b1f
fix type usage in renderers
ndelangen 3c6860b
Build: Use !test tag to disable test-runner tests
yannbf c3ede6b
Write changelog for 8.3.0-alpha.3 [skip ci]
storybook-bot fb78fc5
Bump version from "8.3.0-alpha.2" to "8.3.0-alpha.3" [skip ci]
storybook-bot fc6202e
Scaffold addon-vitest skeleton
ghengeveld 39f688d
Setup addon-vitest in internal Storybook
ghengeveld b82c13a
Some fixes and cleanup
ghengeveld ac23ae6
Load Vitest results from JUnit report and update story statuses accor…
ghengeveld fe5a978
Add onClick handler
ghengeveld edef177
Update @storybook/icons dependency
ghengeveld 1052856
Merge branch 'next' into vitest-integration
yannbf f3433c6
Merge branch 'vitest-integration' into add-vitest-ci-task
yannbf bd1d751
update scripts for nextjs
yannbf ecf1c85
fix
yannbf 8caca19
Merge remote-tracking branch 'origin/next' into add-vitest-ci-task
valentinpalkovic 503de44
Don't mess with the panel position
ghengeveld 8f2c88d
Use internal renderToCanvas method if testingLibaryRender is not spec…
kasperpeulen afd11a8
Merge branch 'next' into kasper/render-agnostic
kasperpeulen ca74d8a
Merge remote-tracking branch 'refs/remotes/origin/next' into vitest-i…
kasperpeulen 81b6775
Fix LinkWrapper on TooltipLinkList stories
ghengeveld d2965c9
Adjust snapshots
kasperpeulen b672f53
Merge remote-tracking branch 'origin/kasper/render-agnostic' into kas…
kasperpeulen 5631f17
Adjust snapshots
kasperpeulen aa18abb
Merge branch 'vitest-integration' into add-vitest-ci-task
yannbf c6ebc2c
Fix hover behavior and search view
ghengeveld d57f328
Merge pull request #28739 from storybookjs/sidebar-story-status-tooltips
yannbf c4dbf12
Merge branch 'vitest-integration' into add-vitest-ci-task
yannbf a076ef1
Revert "disable most CI checks (revert this commit)"
yannbf ab76bac
pass rsc decorators but not the parameters
yannbf 0841ad2
add remark on vitest file
yannbf 2996b7f
Fix tests
kasperpeulen 64a9fa3
Fix build
kasperpeulen 8b59671
fix
yannbf d06ab28
Merge branch 'vitest-integration' into addon-vitest
ghengeveld 07babfe
Fix act errors
kasperpeulen 2241c54
yarn.lock
kasperpeulen 87c6223
Merge pull request #28708 from storybookjs/add-vitest-ci-task
yannbf c62e41d
Merge branch 'vitest-integration' into addon-vitest
yannbf e30bfcc
Fix tests
kasperpeulen 6289999
Merge remote-tracking branch 'refs/remotes/origin/vitest-integration'…
kasperpeulen 21112bc
set up vitest addon in internal storybook
yannbf 31183db
fix formatting
yannbf 257a945
Allow vitest plugin to use composeStories from preview-api
kasperpeulen df69ef5
More reliable status reporting
ghengeveld 89e4a1f
Merge branch 'next' into vitest-integration
yannbf c98e196
Merge branch 'vitest-integration' into addon-vitest
yannbf 81c6a13
rename to experimental
yannbf 072a951
Make it work with the plugin canary release
kasperpeulen 76391dd
Merge remote-tracking branch 'refs/remotes/origin/vitest-integration'…
kasperpeulen 89f3a13
Fix
kasperpeulen f90d77c
strip out junit logic (for now)
yannbf feccff5
Fix null pointer
kasperpeulen e532994
Fix check
kasperpeulen 3f96682
Remove test
kasperpeulen 4300175
wip: add vitest plugin to addon
yannbf ef94fa3
Merge branch 'next' into vitest-integration
yannbf 0760555
Fix cypress test
kasperpeulen 8fde44d
Fix more singleton issues
kasperpeulen 43c0733
Remove redundant svelteVersion prop (was removed earlier)
kasperpeulen 8f39a19
Remove write issue reminder
kasperpeulen 92deb47
Merge pull request #28766 from storybookjs/kasper/render-agnostic
yannbf 6556d03
setup bundling scripts for the vitest addon
yannbf 52aa6fd
Merge branch 'vitest-integration' into yann/addon-vitest-barebones-wi…
yannbf 385879e
fixes
yannbf 7919ead
fix dependencies
yannbf f7de2e2
fix import
yannbf c748186
Merge branch 'next' into vitest-integration
yannbf 632d0e4
Merge branch 'vitest-integration' into yann/addon-vitest-barebones-wi…
yannbf 58dde10
fix version
yannbf dee15b2
fix types
yannbf 6fd386b
fix check command
yannbf 02d0789
fix type generation
yannbf 17ba6e6
Merge branch 'next' into vitest-integration
yannbf f66506e
skip failing svelte tests for now
yannbf a3652bb
Merge branch 'vitest-integration' into yann/addon-vitest-barebones-wi…
yannbf b1e4f7c
enable browser mode
yannbf 1368aef
fix default annotations from nextjs
yannbf 3e33d2e
add storybook script
yannbf 1b89fe1
use istanbul for coverage instead
yannbf e9db42a
add playwright to deps list
yannbf 5f4ded2
Merge branch 'vitest-integration' into yann/fix-nextjs-issues
yannbf 0007c42
Merge branch 'vitest-integration' into yann/addon-vitest-barebones-wi…
yannbf d62a856
use playwright machine for unit tests
yannbf 433bbb5
fix exports order
yannbf 12e0350
remove unnecessary flag from config
yannbf f4bf860
Merge pull request #28810 from storybookjs/yann/addon-vitest-barebone…
yannbf 2e4b199
fix link mode
yannbf 2ffd0d0
fix vue tests
yannbf a5ff402
update vue sandbox scripts
yannbf 24e8a73
Merge branch 'vitest-integration' into yann/fix-nextjs-issues
yannbf e4320b1
Merge pull request #28825 from storybookjs/yann/fix-nextjs-issues
yannbf 633f4b2
Merge branch 'vitest-integration' of github.com:storybookjs/storybook…
yannbf 6d4caba
mock storybook channel in vitest plugin
yannbf 9b4d61c
use vitest tag for filtering
yannbf d5995e3
Fix beforeAll type
kasperpeulen 42d630e
fix issue with double error message
yannbf 1c2888d
Merge branch 'next' into vitest-integration
yannbf 81281ec
move from esbuild to jiti in vitest package.json
yannbf e8364db
support autotitle in vitest plugin
yannbf 722e0d5
add error handling when configDir is incorrect
yannbf 9dc93cc
improve storybook dir calculation
yannbf 2a83669
fix
yannbf 9728c77
cleanup
yannbf 72164de
add browser interactivity api experiment
yannbf f31323d
fix nextjs test
yannbf 40dfa9f
update flaky test
yannbf bffb920
Merge pull request #28847 from storybookjs/yann/support-autotitle
yannbf ee56cca
Merge branch 'next' into vitest-integration
yannbf 53232db
add transformer tests
yannbf b617eb0
Merge remote-tracking branch 'refs/remotes/origin/vitest-integration'…
kasperpeulen 14e18d9
Only set the parameter when the experimentalRSC feature is set
kasperpeulen 4d0744f
Fix filename
kasperpeulen 4c27387
Address feedback
kasperpeulen d1cb751
Address feedback
kasperpeulen 1bf3c4c
fix lint and check issues
yannbf 527e8ea
Merge remote-tracking branch 'refs/remotes/origin/vitest-integration'…
kasperpeulen 49e7932
Merge branch 'refs/heads/vitest-integration' into kasper/refactor-rsc…
kasperpeulen f747943
Fix eslint
kasperpeulen 603ea16
Fix eslint
kasperpeulen 898405e
Merge pull request #28864 from storybookjs/beforeall
kasperpeulen be894e9
Merge pull request #28865 from storybookjs/kasper/refactor-rsc-support
kasperpeulen 7798169
Merge branch 'next' into vitest-integration
yannbf f82153b
fix merge conflicts
yannbf e3f73c9
fix nextjs-vite sandbox generation
yannbf adc1cbb
Merge branch 'next' into vitest-integration
yannbf 8aa5680
fix merge conflict
yannbf 6c6268c
fix lint issue
yannbf c067329
fix test
yannbf b40b33e
fix parallelism
yannbf d3dae46
add vitest tag
yannbf b860bb5
hopefully fix the nextjs issue
yannbf e8805dd
first iteration - babel only
yannbf 7ebafe1
wip
yannbf 89b39a8
use csf-tools for transformation
yannbf 0f15aa1
update lockfile
yannbf 567f11f
fix test
yannbf 3930877
move vitest transformation logic to csf-tools
yannbf c00a80f
reenable browser mode
yannbf 8d0a92a
address review feedback
yannbf 934cefb
readd properties and deprecate them
yannbf c066b8b
fix type issues
yannbf 3861ac4
Merge pull request #28868 from storybookjs/yann/use-babel-in-transfor…
yannbf f2a90a9
Fix unit test
kasperpeulen af8c014
Remove timeout
kasperpeulen d2bc5fb
only set up optimizedeps for nextjs
yannbf 1dbf820
fix plugin duplication
yannbf e2d63c5
fix story name
yannbf f508cc4
fix viewports issue
yannbf 8c580c7
skip channel related tests
yannbf a687a68
fix autotitle
yannbf 4af500e
fix vitest script (some stories might not have any tests)
yannbf 4759c6a
fix viewports usage
yannbf f5f4f5a
warn on unconventional story exports
yannbf 4969596
fix build error
yannbf 8693eaf
fix unit test
yannbf da053e1
skip a few tests, try to fix flake
yannbf 4bf0445
debug hanging nextjs tests
yannbf eb83b88
fix viewport setting
yannbf cb99e97
Add comment
kasperpeulen 251d916
extra fixes
yannbf ba806c1
Merge branch 'vitest-integration' of github.com:storybookjs/storybook…
yannbf 38a154e
Remove comment
kasperpeulen b48ac41
Clean up
kasperpeulen a6df95a
Fix lint
kasperpeulen 1df2ab1
Remove BS
kasperpeulen 13c5361
Cleanup
kasperpeulen 45090b2
Add the composedStory to the context
kasperpeulen 020b6c6
address PR feedback
yannbf 67f5678
fix windows unit tests
yannbf fc07618
fix parallelism and skip more stories
yannbf f773687
increase test timeout
yannbf fddd3a5
fix script
yannbf c12e23e
skip sveltekit tests
yannbf 6cade7d
skip vitest integration in nextjs sandbox
yannbf 659994d
fix typescript issue
yannbf 5f24e86
revamp sandbox setup to move to a workspace file
yannbf bd51a23
change pool options in sandboxes
yannbf 1896a8c
fix style
yannbf f7ff019
more fixes
yannbf 416cd00
Yeah... don't look at this
kasperpeulen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.nx/cache | ||
.nx/cache | ||
.vite-inspect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { beforeAll, vi, expect as vitestExpect } from 'vitest'; | ||
|
||
import { setProjectAnnotations } from '@storybook/react'; | ||
import { userEvent as storybookEvent, expect as storybookExpect } from '@storybook/test'; | ||
|
||
import * as coreAnnotations from '../addons/toolbars/template/stories/preview'; | ||
import * as componentAnnotations from '../core/template/stories/preview'; | ||
// register global components used in many stories | ||
import '../renderers/react/template/components'; | ||
import * as projectAnnotations from './preview'; | ||
|
||
vi.spyOn(console, 'warn').mockImplementation((...args) => console.log(...args)); | ||
|
||
const annotations = setProjectAnnotations([ | ||
// @ts-expect-error check type errors later | ||
projectAnnotations, | ||
// @ts-expect-error check type errors later | ||
componentAnnotations, | ||
coreAnnotations, | ||
{ | ||
// experiment with injecting Vitest's interactivity API over our userEvent while tests run in browser mode | ||
// https://vitest.dev/guide/browser/interactivity-api.html | ||
loaders: async (context) => { | ||
// eslint-disable-next-line no-underscore-dangle | ||
if (globalThis.__vitest_browser__) { | ||
const vitest = await import('@vitest/browser/context'); | ||
const { userEvent: browserEvent } = vitest; | ||
context.userEvent = browserEvent.setup(); | ||
context.expect = vitestExpect; | ||
} else { | ||
context.userEvent = storybookEvent.setup(); | ||
context.expect = storybookExpect; | ||
} | ||
}, | ||
}, | ||
]); | ||
|
||
beforeAll(annotations.beforeAll); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { defaultExclude, defineProject, mergeConfig } from 'vitest/config'; | ||
|
||
import Inspect from 'vite-plugin-inspect'; | ||
|
||
import { vitestCommonConfig } from '../vitest.workspace'; | ||
|
||
const extraPlugins: any[] = []; | ||
if (process.env.INSPECT === 'true') { | ||
// this plugin assists in inspecting the Storybook Vitest plugin's transformation and sourcemaps | ||
extraPlugins.push( | ||
Inspect({ | ||
outputDir: '../.vite-inspect', | ||
build: true, | ||
open: true, | ||
include: ['**/*.stories.*'], | ||
}) | ||
); | ||
} | ||
|
||
export default mergeConfig( | ||
vitestCommonConfig, | ||
defineProject({ | ||
plugins: [ | ||
import('@storybook/experimental-addon-vitest/plugin').then(({ storybookTest }) => | ||
storybookTest({ | ||
configDir: process.cwd(), | ||
}) | ||
), | ||
...extraPlugins, | ||
], | ||
test: { | ||
name: 'storybook-ui', | ||
include: [ | ||
// TODO: test all core and addon stories later | ||
// './core/**/components/**/*.{story,stories}.?(c|m)[jt]s?(x)', | ||
'../addons/interactions/src/**/*.{story,stories}.?(c|m)[jt]s?(x)', | ||
], | ||
exclude: [ | ||
...defaultExclude, | ||
'../node_modules/**', | ||
'**/__mockdata__/**', | ||
// expected to fail in Vitest because of fetching /iframe.html to cause ECONNREFUSED | ||
'**/Zoom.stories.tsx', | ||
], | ||
browser: { | ||
enabled: true, | ||
name: 'chromium', | ||
provider: 'playwright', | ||
headless: true, | ||
screenshotFailures: false, | ||
}, | ||
setupFiles: ['./storybook.setup.ts'], | ||
environment: 'happy-dom', | ||
}, | ||
}) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
check: Consider providing examples or more detailed guidance on how to migrate from the deprecated
experimental_SIDEBAR_TOP
and removedexperimental_SIDEBAR_BOTTOM
addon types.