Skip to content

Commit

Permalink
test(visual): change method to wait for image (PostHog#23906)
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr authored and silentninja committed Aug 8, 2024
1 parent 1f58d21 commit 81ed316
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ async function expectStoryToMatchSnapshot(
})

// Wait for all images to load
await page.waitForFunction(() => Array.from(document.images).every((i: HTMLImageElement) => i.complete))
await waitForPageReady(page)
await page.waitForLoadState('networkidle')
await page.waitForFunction(() => Array.from(document.images).every((i: HTMLImageElement) => !!i.naturalWidth))
await page.waitForTimeout(2000)

await check(page, context, browser, 'light', storyContext.parameters?.testOptions?.snapshotTargetSelector)
Expand All @@ -174,9 +173,8 @@ async function expectStoryToMatchSnapshot(
})

// Wait for all images to load
await page.waitForFunction(() => Array.from(document.images).every((i: HTMLImageElement) => i.complete))
await waitForPageReady(page)
await page.waitForLoadState('networkidle')
await page.waitForFunction(() => Array.from(document.images).every((i: HTMLImageElement) => !!i.naturalWidth))
await page.waitForTimeout(100)

await check(page, context, browser, 'dark', storyContext.parameters?.testOptions?.snapshotTargetSelector)
Expand Down

0 comments on commit 81ed316

Please sign in to comment.