From 329507f9cd13085ff30fbd81c067541b97ddfd89 Mon Sep 17 00:00:00 2001 From: Oleg Gaydarenko Date: Tue, 6 Mar 2018 13:39:49 +0300 Subject: [PATCH] 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 - https://github.com/GoogleChrome/puppeteer/blob/c857aef5893042ac2f8b587283683396ae9c333b/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 --- addons/storyshots/src/test-body-image-snapshot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/storyshots/src/test-body-image-snapshot.js b/addons/storyshots/src/test-body-image-snapshot.js index 5f95c5666ef2..e010b50e98ae 100644 --- a/addons/storyshots/src/test-body-image-snapshot.js +++ b/addons/storyshots/src/test-body-image-snapshot.js @@ -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.`,