Skip to content

Commit

Permalink
Fix PreviewWeb extract running against old SB
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Feb 10, 2022
1 parent c49fbf0 commit 609a595
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/cli/src/extract.ts
Expand Up @@ -11,9 +11,12 @@ const read = async (url: string) => {

await page.goto(url);

await page.waitForFunction(
'window.__STORYBOOK_PREVIEW__ && window.__STORYBOOK_PREVIEW__.extract && window.__STORYBOOK_PREVIEW__.extract()'
);
// we don't know whether we are running against a new or old storybook
// FIXME: add tests for both
await page.waitForFunction(`
(window.__STORYBOOK_PREVIEW__ && window.__STORYBOOK_PREVIEW__.extract && window.__STORYBOOK_PREVIEW__.extract()) ||
(window.__STORYBOOK_STORY_STORE__ && window.__STORYBOOK_STORY_STORE__.extract && window.__STORYBOOK_STORY_STORE__.extract())
`);
const data = JSON.parse(
await page.evaluate(async () => {
// eslint-disable-next-line no-undef
Expand Down

0 comments on commit 609a595

Please sign in to comment.