From a2997927cac7e3e6217843ef725bef44ce4eb16f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Obermu=CC=88ller?= Date: Fri, 9 Aug 2024 11:12:21 +0200 Subject: [PATCH] try awaiting viewport change --- .storybook/test-runner.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.storybook/test-runner.ts b/.storybook/test-runner.ts index 026a3f786ada3..2b063912c9c8e 100644 --- a/.storybook/test-runner.ts +++ b/.storybook/test-runner.ts @@ -81,6 +81,7 @@ module.exports = { const storyContext = await getStoryContext(page, context) const viewport = storyContext.parameters?.testOptions?.viewport || DEFAULT_VIEWPORT await page.setViewportSize(viewport) + await page.waitForFunction(() => window.innerWidth == viewport.width) }, async postVisit(page, context) { ATTEMPT_COUNT_PER_ID[context.id] = (ATTEMPT_COUNT_PER_ID[context.id] || 0) + 1 @@ -95,6 +96,7 @@ module.exports = { // just in case the retry is due to a useResizeObserver fail await page.setViewportSize({ width: 1920, height: 1080 }) await page.setViewportSize(viewport) + await page.waitForFunction(() => window.innerWidth == viewport.width) } const browserContext = page.context() const { snapshotBrowsers = ['chromium'] } = storyContext.parameters?.testOptions ?? {}