From 0e063f58decc520789530d899be753267a706294 Mon Sep 17 00:00:00 2001 From: Hypnosphi Date: Mon, 19 Feb 2018 23:39:49 +0300 Subject: [PATCH] Integration tests: wait until stories appear --- integration/examples.test.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/integration/examples.test.js b/integration/examples.test.js index ba023d359238..69ccf278baf0 100644 --- a/integration/examples.test.js +++ b/integration/examples.test.js @@ -23,18 +23,21 @@ const examples = [ { name: 'cra-kitchen-sink', storybookUrl: pathToCraKitchenSink, + storySelector: '#root *', }, { name: 'vue-kitchen-sink', storybookUrl: pathToVueKitchenSink, + storySelector: '#root *', }, { name: 'angular-cli', storybookUrl: pathToAngularKitchenSink, + storySelector: 'storybook-dynamic-app-root *', }, ]; -examples.forEach(({ name, storybookUrl }) => { +examples.forEach(({ name, storybookUrl, storySelector }) => { let browser = puppeteer.launch(); let page; @@ -50,6 +53,8 @@ examples.forEach(({ name, storybookUrl }) => { it(`Take screenshots for '${name}'`, async () => { await page.goto(`file://${storybookUrl}`); + const iframe = page.mainFrame().childFrames()[0]; + await iframe.waitFor(storySelector); const screenshot = await page.screenshot({ fullPage: true }); expect(screenshot).toMatchImageSnapshot({ failureThreshold: 0.04, // 4% threshold,