intuit/proof

__STORYBOOK_CLIENT_API__ is not defined

Closed this issue · 4 comments

Long shot here; My proof command is failing with Request failed with status 500 due to javascript error: __STORYBOOK_CLIENT_API__ is not defined. It's only failing in a jenkins automation environment. It seems to switch to the iframe correctly. Does anyone have any clever ideas? This is the command yarn ds proof -u ${url} -vvv --headless --browser-name chrome.

Okay did some more digging here. This can be reproduced locally by running yarn proof -u your-storybook-url. The problem is that the iFrame actually takes a bit longer to load than it takes for the '#root' "to exist" (sometimes quite a bit longer). That creates a race condition where the getStories function fires too soon and the global variable __STORYBOOK_CLIENT_API__ is not present. Also, it turns out the waitForExist method is pretty sketchy in general here because you need the javascript to load in order to call getStories. The only thing i found to work was to put a browser.pause right before the the switchToFrame. Which is also sketchy...

Thanks for looking into this. I haven't hit this issue in the projects we use, but i can definitely see the timing being an issue.

We could potentially defer the switchToFrame call into the retry loop we do here. That would give the frame + js some more time to load before erroring out.

Okay, I created a PR. If it gets merged could I get access to a pre-release? I suddenly was not able to replicate the problem locally, so would like to test the fix.

Closed by #55