Skip to content

Commit

Permalink
Merge pull request #92 from happo/addons-channel-v7
Browse files Browse the repository at this point in the history
Stop getting addons channel from @storybook/addons
  • Loading branch information
trotzig authored Mar 22, 2023
2 parents 853370f + 5a9d610 commit 7d8933e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/register.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { addons } from '@storybook/addons';

const { SB_ROOT_ELEMENT_SELECTOR } = require('./constants');

const time = window.happoTime || {
Expand Down Expand Up @@ -163,21 +161,20 @@ window.happo.nextExample = async () => {
console.error('Failed to invoke afterScreenshot hook', e);
}
}
const channel = addons.getChannel();
channel.emit('setCurrentStory', {
window.__STORYBOOK_ADDONS_CHANNEL__.emit('setCurrentStory', {
kind: component,
story: variant,
storyId,
});
await new Promise((resolve) => time.originalSetTimeout(resolve, 0));
if (theme && themeSwitcher) {
await themeSwitcher(theme, channel);
await themeSwitcher(theme, window.__STORYBOOK_ADDONS_CHANNEL__);
}
await waitForSomeContent(rootElement);
if (/sb-show-errordisplay/.test(document.body.className)) {
// It's possible that the error is from unmounting the previous story. We
// can try re-rendering in this case.
channel.emit('forceReRender');
window.__STORYBOOK_ADDONS_CHANNEL__.emit('forceReRender');
await waitForSomeContent(rootElement);
}
if (beforeScreenshot && typeof beforeScreenshot === 'function') {
Expand Down

0 comments on commit 7d8933e

Please sign in to comment.