Skip to content

Commit c7f561c

Browse files
authored
test: refactor to use toHaveScreenshot (#1314)
1 parent 116d250 commit c7f561c

File tree

8 files changed

+4
-13
lines changed

8 files changed

+4
-13
lines changed

.github/workflows/actions/test-e2e/action.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@ runs:
5555
npx playwright test --shard=${{ inputs.shard }}/${{ inputs.totalShards }} --update-snapshots
5656
git add src/\*.png --force
5757
mkdir updated-screenshots
58-
echo 'made dir'
5958
rsync -R --progress $(git diff --name-only --cached) updated-screenshots
60-
echo 'copied images'
61-
if [ -d updated-screenshots ]; then
59+
if [ "$(ls -A updated-screenshots)" ]; then
6260
echo "hasUpdatedScreenshots=$(echo 'true')" >> $GITHUB_OUTPUT
6361
cd updated-screenshots
6462
ls

playwright.config.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,7 @@ const config: PlaywrightTestConfig = {
5252
* Maximum time expect() should wait for the condition to be met.
5353
* For example in `await expect(locator).toHaveText();`
5454
*/
55-
timeout: 5000,
56-
toMatchSnapshot: {
57-
/**
58-
* Increases the maximum allowed pixel difference to account
59-
* for slight browser rendering inconsistencies.
60-
*/
61-
maxDiffPixelRatio: 0.02
62-
}
55+
timeout: 5000
6356
},
6457
/* Fail the build on CI if you accidentally left test.only in the source code. */
6558
forbidOnly: !!process.env.CI,

src/components/icon/test/icon.e2e.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test.describe('icon: basic', () => {
88
// Wait for all SVGs to be lazily loaded before taking screenshots
99
await page.waitForLoadState('networkidle');
1010

11-
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot(`icon-diff.png`);
11+
await expect(page).toHaveScreenshot(`icon-diff.png`, { fullPage: true });
1212
});
1313

1414
test('some icons should flip when rtl', async ({ page }) => {
Loading
Loading

src/components/test/dynamic-type/icon.e2e.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test.describe('icon: dynamic type', () => {
1313

1414
const icons = page.locator('#icons');
1515

16-
expect(await icons.screenshot()).toMatchSnapshot(`icon-dynamic-type-diff.png`);
16+
await expect(icons).toHaveScreenshot(`icon-dynamic-type-diff.png`);
1717
});
1818

1919
});

0 commit comments

Comments
 (0)