Add 'waitUntil' option to puppeteer of storyshots

If some elements use additional xhr requests (like async image loading).
Puppeteer might not imprint the end state of the page. Puppeteer has
built-in method to resolve this -
c857aef589/docs/api.md (pagegotourl-options)

This option is fairly general so it should be okay to use for other cases
as well.

However, 'beforeScreenshot' could be used instead, but proposed approach seems
more definite and reliable

As additional further improvement, these `goto` options might be exposed to
consumber as well
This commit is contained in:
Oleg Gaydarenko 2018-03-06 13:39:49 +03:00
parent cad61533c9
commit 329507f9cd

View File

@ -36,7 +36,7 @@ export const imageSnapshot = ({
expect.assertions(1);
return page
.goto(url)
.goto(url, {"waitUntil" : "networkidle0"})
.catch(e => {
logger.error(
`ERROR WHILE CONNECTING TO ${url}, did you start or build the storybook first ? A storybook instance should be running or a static version should be built when using image snapshot feature.`,