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
After the introduction of #592, the global state (styles, etc.) of the page are not reset across snapshots. We came across this issues when testing modals, libraries like bootstrap edit the body element. A possible solution is to provide an option to refresh the page per snapshot.
Our workaround solution is to add this to preview.jsx:
channel.on(CURRENT_STORY_WAS_SET, () => {
// reset global state here...
document.body.removeAttribute('style');
});
// simulate snapshot by using storybook's channel
window.__STORYBOOK_PREVIEW__?.channel.emit('setCurrentStory', { storyId: '<story-1>' });
// story-1 sets a global property
document.body.style.paddingRight = '16px'
// navigate to another story
window.__STORYBOOK_PREVIEW__?.channel.emit('setCurrentStory', { storyId: '<story-2>' });
// body will have 'padding-right: 16px', expected ''
document.body.style.paddingRight
The text was updated successfully, but these errors were encountered:
The problem
After the introduction of #592, the global state (styles, etc.) of the page are not reset across snapshots. We came across this issues when testing modals, libraries like bootstrap edit the
body
element. A possible solution is to provide an option to refresh the page per snapshot.Our workaround solution is to add this to
preview.jsx
:Environment
Code to reproduce issue
The text was updated successfully, but these errors were encountered: