Is there a way to execute setup and cleanup steps for a story in Storybook? Say, for example, I have a component that behaves differently contingent on the presence or value of some piece of local storage, or a property set on window
. I would like to be able to setup a story so that but also cleanup so that it does not inadvertently carry over to other stories.
If there is no official suggested best practice, I would think the best way to do this is to make a custom decorator that wraps the story in a component with setup and teardown lifecycle events (I am using Storybook with React in this case, FYI). Open to other ideas.