You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The changes in 8.5.0 to the vite plugin which updates the vitest config overwrites the commands setting applied in a workspace file.
There is a workaround which is to register a plugin after the testStorybook plugin and inject the commands there, but this shouldnt be required and should retain the existing commands registered:
import{storybookTest}from"@storybook/experimental-addon-test/vitest-plugin";import{defineWorkspace}from"vitest/config";import*ascommandsfrom"./.storybook/vitest.commands";exportdefaultdefineWorkspace(["vite.config.ts",{extends: "vite.config.ts",plugins: [storybookTest({configDir: ".storybook"}),// having to register my commands here because merged config has them removed.{enforce: "pre",name: "patch-vitest-browser-commands",config(config){config.test.browser.commands={
...config.test.browser.commands,
...commands,};returnconfig;},},],test: {//...browser: {// these are ignore/removed
commands
}}}]);
Reproduction link
na
Reproduction steps
register commands in vitest browser config object
note these commands are not available during tests
leemason
changed the title
[Bug]: experimental test addon prevents custom vitest commands being registered
[Bug]: experimental test addon ^8.5.0 prevents custom vitest commands being registered
Jan 24, 2025
** Disclaimer** This information might be inaccurate, due to it being generated automatically
This appears to be an issue in the @storybook/experimental-addon-test Vitest plugin where the test configuration is overwriting custom commands instead of merging them. The fix would be in code/addons/test/src/vitest-plugin.ts to ensure the browser commands are merged rather than replaced.
Specific implementation:
Modify the config merge logic in the storybookTest plugin to preserve existing browser commands:
Describe the bug
The changes in 8.5.0 to the vite plugin which updates the vitest config overwrites the commands setting applied in a workspace file.
There is a workaround which is to register a plugin after the
testStorybook
plugin and inject the commands there, but this shouldnt be required and should retain the existing commands registered:Reproduction link
na
Reproduction steps
System
Additional context
No response
The text was updated successfully, but these errors were encountered: