Skip to content

Commit

Permalink
fix(runner-storybook): Wait for configuring store
Browse files Browse the repository at this point in the history
  • Loading branch information
Quramy committed Nov 26, 2020
1 parent 8dce189 commit 9daccd0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/acot-runner-storybook/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ declare global {
interface Window {
__STORYBOOK_CLIENT_API__: {
raw: () => Story[];
store: () => {
_configuring?: boolean; // This parameter is enabled with SB v6 or later
};
};
}
}
Expand Down Expand Up @@ -112,6 +115,12 @@ export default createRunnerFactory<Options>(
await page.goto(`${config.origin}/iframe.html?id=__ACOTSTORYBOOK__`);
await page.waitForFunction(() => window.__STORYBOOK_CLIENT_API__);

// SB(v6 or later) api's `raw()` can return empty array til SB store gets configured.
// See https://github.com/storybookjs/storybook/pull/9914 .
await page.waitForFunction(
() => window.__STORYBOOK_CLIENT_API__.store()._configuring !== true,
);

const raw = await page.evaluate(() => {
return window.__STORYBOOK_CLIENT_API__.raw().map((o) => ({
id: o.id,
Expand Down

0 comments on commit 9daccd0

Please sign in to comment.