Skip to content

Commit 3662927

Browse files
Add cross-platform visual test tolerance for CI
Font rendering differs between macOS (Core Text) and Linux (FreeType), causing ~2% pixel mismatch in Firefox visual tests. Allow 2.5% tolerance in CI only; local tests remain exact match (0%). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 05b3404 commit 3662927

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

tests/firefox/extension.spec.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,10 @@ describe('Navigation', function () {
468468
// Dynamic content is frozen after loading for deterministic baselines.
469469
// ============================================================
470470

471+
// Cross-platform font rendering tolerance: macOS baselines vs Linux in CI.
472+
// Matches Playwright's maxDiffPixelRatio: 0.02 (2%) for Chrome visual tests.
473+
const VISUAL_MISMATCH_TOLERANCE = process.env.CI ? 2.5 : 0;
474+
471475
describe('Visual', function () {
472476
beforeEach(async function () {
473477
await clearAllStorage();
@@ -496,15 +500,15 @@ describe('Visual', function () {
496500
});
497501
await browser.pause(500);
498502

499-
await expect(browser).toMatchFullPageSnapshot('popup-with-issues');
503+
await expect(browser).toMatchFullPageSnapshot('popup-with-issues', VISUAL_MISMATCH_TOLERANCE);
500504
});
501505

502506
it('popup empty state', async function () {
503507
await browser.url(popupUrl());
504508
await $('#empty-state').waitForDisplayed({ timeout: 10000 });
505509
await browser.pause(300);
506510

507-
await expect(browser).toMatchFullPageSnapshot('popup-empty');
511+
await expect(browser).toMatchFullPageSnapshot('popup-empty', VISUAL_MISMATCH_TOLERANCE);
508512
});
509513

510514
it('popup import section', async function () {
@@ -515,14 +519,14 @@ describe('Visual', function () {
515519
await $('#import-section').waitForDisplayed({ timeout: 5000 });
516520
await browser.pause(300);
517521

518-
await expect(browser).toMatchFullPageSnapshot('popup-import');
522+
await expect(browser).toMatchFullPageSnapshot('popup-import', VISUAL_MISMATCH_TOLERANCE);
519523
});
520524

521525
it('options default state', async function () {
522526
await browser.url(optionsUrl());
523527
await browser.pause(500);
524528

525-
await expect(browser).toMatchFullPageSnapshot('options-default');
529+
await expect(browser).toMatchFullPageSnapshot('options-default', VISUAL_MISMATCH_TOLERANCE);
526530
});
527531

528532
it('options with token configured', async function () {
@@ -536,6 +540,6 @@ describe('Visual', function () {
536540
await browser.url(optionsUrl());
537541
await browser.pause(500);
538542

539-
await expect(browser).toMatchFullPageSnapshot('options-configured');
543+
await expect(browser).toMatchFullPageSnapshot('options-configured', VISUAL_MISMATCH_TOLERANCE);
540544
});
541545
});

0 commit comments

Comments
 (0)