Skip to content

Commit

Permalink
Try waitFor
Browse files Browse the repository at this point in the history
  • Loading branch information
nmanu1 committed Nov 29, 2023
1 parent 0b1a7a2 commit b24d5d0
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions .storybook/snapshots/test-runner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Page } from 'playwright-core';
import { TestRunnerConfig, TestContext } from '@storybook/test-runner';
import { toMatchImageSnapshot } from 'jest-image-snapshot';
import { waitFor } from '@testing-library/react';

const customSnapshotsDir = `${process.cwd()}/.storybook/snapshots/__snapshots__`;

Expand All @@ -13,15 +14,22 @@ const renderFunctions: TestRunnerConfig = {
expect.extend({ toMatchImageSnapshot });
},
async postVisit(page: Page, context: TestContext) {
if (context.id.startsWith("mapboxmap--") || context.id.startsWith("geolocation--")) {
await page.waitForTimeout(2000);
}
// if (context.id.startsWith("mapboxmap--")) {
// await page.waitForTimeout(3000);
// }

const image = await page.screenshot();
expect(image).toMatchImageSnapshot({
customSnapshotsDir,
customSnapshotIdentifier: context.id,
});
await waitFor(async () => {
const image = await page.screenshot();
expect(image).toMatchImageSnapshot({
customSnapshotsDir,
customSnapshotIdentifier: context.id,
});
})
// const image = await page.screenshot();
// expect(image).toMatchImageSnapshot({
// customSnapshotsDir,
// customSnapshotIdentifier: context.id,
// });
},
};

Expand Down

0 comments on commit b24d5d0

Please sign in to comment.