Skip to content

Commit

Permalink
chore(ci): reconfigure percy to only snapshot mobile in the white the…
Browse files Browse the repository at this point in the history
…me (#14886)

Co-authored-by: Guilherme Datilio Ribeiro <guilhermedatilio@gmail.com>
  • Loading branch information
tay1orjones and guidari authored Oct 16, 2023
1 parent fa9c18c commit c9ad02f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions .percy.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Percy config
version: 2
snapshot:
widths:
Expand Down
13 changes: 12 additions & 1 deletion e2e/test-utils/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,21 @@ const { expect } = require('@playwright/test');
async function snapshot(page, context) {
const id = getSnapshotId(context);

/**
* Restrict mobile snapshots to only the white theme. There's not really a strong
* reason for snapshotting components across 4 themes in mobile as components don't
* really have different visual states per breakpoint, per theme.
* The overall thinking is that if a bug appears in white, it'll be the same bug
* present in all other themes.
* This configuration overrides any global setting for `widths` in .percy.yml or otherwise.
* See https://github.com/carbon-design-system/carbon/issues/14779
*/
const widths = context.themes === 'white' ? [1366, 360] : [1366];

if (process.env.ENABLE_LOCAL_SNAPSHOTS) {
expect(await page.screenshot()).toMatchSnapshot(`${id}.png`);
} else {
await percySnapshot(page, id);
await percySnapshot(page, id, { widths: widths });
}
}

Expand Down

0 comments on commit c9ad02f

Please sign in to comment.