I'm struggling a bit with interactions in Storybook. What I wanted to achieve was to write some UI tests using interactions and execute those tests in pipeline. But I see some problems, i.e.
Has anyone worked out any approach for similar use case?
In my team we are starting to do more storybook testing and less standard @testing-library/react
tests, especially for more complex components. This is what we have found so far:
@testing-library/react
anyway, writing tests feels very similarly with the added bonus that we can see what we are doing.story
per use-case. Within that use case we create several steps
to document/indicate what we are trying to do.actions
tab polluted. This is usually our Primary
story.canvasElement
. For this use-case, storybook recommends using the screen
element instead of the canvasElement
. We also setup a wrapper button for modals, though we only use it for the Primary
and let the modals be shown by default for the other use-cases.Some things that we are missing/not tried yet with storybook testing:
storybook-addon-manual-mocks
library to mock things like uuid
, etc. This mocks globally, for all tests.All-in-all, we are really happy with storybook testing for setting up different usecases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With