storybook: Switch from @storybook/test-runner to @storybook/addon-vitest#47802
storybook: Switch from @storybook/test-runner to @storybook/addon-vitest#47802
@storybook/test-runner to @storybook/addon-vitest#47802Conversation
…vitest` `@storybook/test-runner` does not seem very well maintained upstream; the package's readme itself urges switching to `@storybook/addon-vitest` when possible. This also require switching from building the storybook using webpack to using vite. Which turned out to be a somewhat big lift, several vite/esbuild issues needed working around.
|
|
||
| expect-playwright@0.8.0: | ||
| resolution: {integrity: sha512-+kn8561vHAY+dt+0gMqqj1oY+g5xWrsuGMk4QGxotT2WS545nVqqjs37z6hrYfIuucwqthzwJfCJUEYqixyljg==} | ||
| deprecated: ⚠️ The 'expect-playwright' package is deprecated. The Playwright core assertions (via @playwright/test) now cover the same functionality. Please migrate to built-in expect. See https://playwright.dev/docs/test-assertions for migration. |
There was a problem hiding this comment.
Getting rid of this and a few other deprecated deps is really one of my main motivations for doing this. 😀
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Boost plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
tbradsha
left a comment
There was a problem hiding this comment.
All the commands seemed to work. I needed to install Playwright before running tests (which is what the workflow does too).
Notably, the time to preview went from 15s to well under a second. And nice dependency cleanup!
The config is largely over my head, but things seem to run fine. trunk had a few errors that this branch did not (the jetpackConfig one is hacked around, but I'm not sure why the other one no longer shows):
▲ Module not found: Error: Can't resolve 'jetpackConfig' in
│ '/Users/tmb/GitHub/jetpack/projects/js-packages/config/src'
│
▲ Module not found: Error: Can't resolve '@emotion/is-prop-valid' in
│ '/Users/tmb/GitHub/jetpack/node_modules/.pnpm/framer-motion@11.18.2_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/framer-motion/dist/es/render/dom/utils'
| plugin.definitions[ 'process.env' ][ key ] = JSON.stringify( customEnvVariables[ key ] ); | ||
| } ); | ||
| // Stub `@automattic/jetpack-config`, the whole `jetpackConfig` thing confuses Storybook/vite/vitest/esbuild/rolldown/etc to no end. | ||
| // If you're trying to use those tools for something else, consider somehow fixing `@automattic/jetpack-config` instead of perpetuating this hack. |
| 'projects/plugins/protect/src/js/components', | ||
| ].map( project => path.join( basedir, project ) ); |
There was a problem hiding this comment.
Presuming we're always in projects, we could consider something like:
...
'projects/plugins/protect/src/js/components',
].map( project => path.join( basedir, 'projects', project ) );
There was a problem hiding this comment.
That would produce /path/to/jetpack/projects/projects/plugins/protect/src/js/components. Unless you meant removing projects/ from all the entries in the array above too but forgot to do that, in which case I think I'd rather keep the "full" path in the array. Less confusing that way.
There was a problem hiding this comment.
Yes, I meant to remove projects/ from all the entries above in my example. But no worries.
The chart svg is displaying inline rather than block, which means the containing block wants to leave an additional few px for descenders. This normally doesn't matter, since the flexbox constraints and `min-height: 0` on the parent divs usually winds up restricting the container's height regardless. In headless Chrome, however, this isn't working: the container doesn't shrink away the extra px for the descenders, then `withResponsive` resizes the chart to take up the extra space, which makes the container expand by a few more pixels, rinse, repeat. Setting the svg as `display: block` prevents the space being left for the descenders in the first place, so the whole tag stack stays at the intended size.
| // The svg displaying inline includes a few px for descenders, which | ||
| // confuses some browser environments (e.g. headless Chrome) into | ||
| // constantly growing the container. Setting it to display as block avoids | ||
| // that. |
There was a problem hiding this comment.
@Automattic/red I think Charts is your thing, does this seem like a good fix for the problem to you? Thanks. 🙂
Proposed changes
@storybook/test-runnerdoes not seem very well maintained upstream; the package's readme itself urges switching to@storybook/addon-vitestwhen possible.This also require switching from building the storybook using webpack to using vite. Which turned out to be a somewhat big lift, several vite/esbuild issues needed working around.
Other information
Related product discussion/links
None
Does this pull request change what data or activity we track or use?
No
Testing instructions
projects/js-packages/storybook, try runningpnpm storybook:build,pnpm storybook:test, andpnpm storybook:dev. Do they all work?