Skip to content

Commit

Permalink
Use waitForPageReady()
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed Nov 23, 2023
1 parent 61b8902 commit f68a285
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { toMatchImageSnapshot } from 'jest-image-snapshot'
import { getStoryContext, TestRunnerConfig, TestContext } from '@storybook/test-runner'
import { getStoryContext, TestRunnerConfig, TestContext, waitForPageReady } from '@storybook/test-runner'
import type { Locator, Page, LocatorScreenshotOptions } from '@playwright/test'
import type { Mocks } from '~/mocks/utils'
import { StoryContext } from '@storybook/types'
Expand Down Expand Up @@ -110,8 +110,7 @@ async function expectStoryToMatchSnapshot(
check = expectStoryToMatchComponentSnapshot
}

// Wait for story to load
await page.waitForSelector('.sb-show-preparing-story', { state: 'detached' })
await waitForPageReady(page)
await page.evaluate(() => {
// Stop all animations for consistent snapshots
document.body.classList.add('storybook-test-runner')
Expand All @@ -123,7 +122,7 @@ async function expectStoryToMatchSnapshot(
await page.waitForSelector(waitForSelector)
}

await page.waitForTimeout(400) // Wait for animations to finish
await page.waitForTimeout(100) // Wait for effects to finish

// Wait for all images to load
await page.waitForFunction(() =>
Expand Down

0 comments on commit f68a285

Please sign in to comment.