From 943b595811366a121b752222889cb9d0cdada9e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Obermu=CC=88ller?= Date: Fri, 9 Aug 2024 11:21:17 +0200 Subject: [PATCH] wip --- .storybook/test-runner.ts | 6 ++++-- playwright.config.ts | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.storybook/test-runner.ts b/.storybook/test-runner.ts index 2b063912c9c8e..9132d8660cd9b 100644 --- a/.storybook/test-runner.ts +++ b/.storybook/test-runner.ts @@ -80,8 +80,9 @@ module.exports = { async preVisit(page, context) { const storyContext = await getStoryContext(page, context) const viewport = storyContext.parameters?.testOptions?.viewport || DEFAULT_VIEWPORT + const viewPortChange = page.waitForFunction(() => window.innerWidth === viewport.width) await page.setViewportSize(viewport) - await page.waitForFunction(() => window.innerWidth == viewport.width) + await viewPortChange }, async postVisit(page, context) { ATTEMPT_COUNT_PER_ID[context.id] = (ATTEMPT_COUNT_PER_ID[context.id] || 0) + 1 @@ -95,8 +96,9 @@ module.exports = { // When retrying, resize the viewport and then resize again to default, // just in case the retry is due to a useResizeObserver fail await page.setViewportSize({ width: 1920, height: 1080 }) + const viewPortChange = page.waitForFunction(() => window.innerWidth === viewport.width) await page.setViewportSize(viewport) - await page.waitForFunction(() => window.innerWidth == viewport.width) + await viewPortChange } const browserContext = page.context() const { snapshotBrowsers = ['chromium'] } = storyContext.parameters?.testOptions ?? {} diff --git a/playwright.config.ts b/playwright.config.ts index a31aa1543f192..f1d0c1b524eb4 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -47,6 +47,11 @@ export default defineConfig({ name: 'chromium', use: { ...devices['Desktop Chrome'], + viewport: null, + launchOptions: { + ...devices['Desktop Chrome']['launchOptions'], + args: ['--window-size=1280,720'], + }, }, },