Monitor React state changes from Storybook side to improve test suite stability #30210
Unanswered
dpizzolongo
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Is it possible to monitor React states from Storybook side for stability purposes? The goal would be to wait for the component to be ready (after state or prop changes) before making test assertions. I know that the
@storybook/test
package provides thewaitFor
function to evaluate test assertions until a timeout expires, but I would like to have a more sophisticated and stable solution.I was able to implement this successfully with React class components, but I would like to be able to do the same with React functional components. This solution uses
spyOn
which spies oncomponentDidUpdate
lifecycle function to return{ fetchIsComplete: true, componentIsReady: true }
before asserting the final state of the component.TestComponent.tsx
TestComponent.stories.tsx
Additional information
No response
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions