[Bug]: useArgs
from Preview API has no effect when running Vitest addon from CLI
#30207
Labels
useArgs
from Preview API has no effect when running Vitest addon from CLI
#30207
Describe the bug
This bug applies to the experimental Vitest Test Addon.
When testing (i.e
play
function) a controlled component that is connected to the Storyargs
viauseArgs
, the tests pass when run within the Storybook UI, but fail when run from the Vitest CLI. I don't expect the tests to behave differently depending on how they are run.Deconstructing
setArgs
fromuseArgs
and calling it in a change handler is a common approach for creating Stories for controlled components. The issue occurs whensetArgs
is called during the execution of theplay
function. For example, when typing into an input whose change handler callssetArgs
. In the Storybook UI,setArgs
works as expected and the story re-renders with the new state. In the Vitest CLI, however,setArgs
seems to have no effect and the story does not re-render.In the reproduction I created, the attributes of an
input
element change depending on theargs
. Theplay
function asserts the value of an attribute. This example is contrived, but mimics the actual use case I have in which the component renders different elements based on the args.Reproduction link
https://github.com/adriantrunzo/sb-useargs-test
Reproduction steps
pnpm install
pnpm storybook
pnpm vitest
and verify that they failSystem
Additional context
No response
The text was updated successfully, but these errors were encountered: