diff --git a/test/e2e/onFCP-test.js b/test/e2e/onFCP-test.js index b2797cc0..67ade203 100644 --- a/test/e2e/onFCP-test.js +++ b/test/e2e/onFCP-test.js @@ -21,6 +21,23 @@ import {navigateTo} from '../utils/navigateTo.js'; import {stubForwardBack} from '../utils/stubForwardBack.js'; import {stubVisibilityChange} from '../utils/stubVisibilityChange.js'; +// Temp fix to address Firefox flakiness. +// See https://github.com/GoogleChrome/web-vitals/issues/472 +const originalStrictEqual = assert.strictEqual; +assert.strictEqual = function (actual, expected, message) { + if ( + browser.capabilities.browserName === 'firefox' && + (expected === 'good' || expected === 'needs-improvement') && + actual !== expected + ) { + console.error( + `Override assert for Firefox (actual: ${actual}, expected: ${expected})`, + ); + return true; + } + return originalStrictEqual(actual, expected, message); +}; + describe('onFCP()', async function () { // Retry all tests in this suite up to 2 times. this.retries(2); @@ -173,11 +190,7 @@ describe('onFCP()', async function () { assert(fcp1.id.match(/^v4-\d+-\d+$/)); assert.strictEqual(fcp1.name, 'FCP'); assert.strictEqual(fcp1.value, fcp1.delta); - // Temp fix to address Firefox flakiness. - // See https://github.com/GoogleChrome/web-vitals/issues/472 - if (browser.capabilities.browserName !== 'firefox') { - assert.strictEqual(fcp1.rating, 'good'); - } + assert.strictEqual(fcp1.rating, 'good'); assert.strictEqual(fcp1.entries.length, 1); assert.match(fcp1.navigationType, /navigate|reload/); @@ -192,11 +205,7 @@ describe('onFCP()', async function () { assert(fcp2.id !== fcp1.id); assert.strictEqual(fcp2.name, 'FCP'); assert.strictEqual(fcp2.value, fcp2.delta); - // Temp fix to address Firefox flakiness. - // See https://github.com/GoogleChrome/web-vitals/issues/472 - if (browser.capabilities.browserName !== 'firefox') { - assert.strictEqual(fcp2.rating, 'good'); - } + assert.strictEqual(fcp2.rating, 'good'); assert.strictEqual(fcp2.entries.length, 0); assert.strictEqual(fcp2.navigationType, 'back-forward-cache'); @@ -211,11 +220,7 @@ describe('onFCP()', async function () { assert(fcp3.id !== fcp2.id); assert.strictEqual(fcp3.name, 'FCP'); assert.strictEqual(fcp3.value, fcp3.delta); - // Temp fix to address Firefox flakiness. - // See https://github.com/GoogleChrome/web-vitals/issues/472 - if (browser.capabilities.browserName !== 'firefox') { - assert.strictEqual(fcp3.rating, 'good'); - } + assert.strictEqual(fcp3.rating, 'good'); assert.strictEqual(fcp3.entries.length, 0); assert.strictEqual(fcp3.navigationType, 'back-forward-cache'); }); diff --git a/test/e2e/onLCP-test.js b/test/e2e/onLCP-test.js index 4f92fb36..94f708c9 100644 --- a/test/e2e/onLCP-test.js +++ b/test/e2e/onLCP-test.js @@ -22,6 +22,23 @@ import {navigateTo} from '../utils/navigateTo.js'; import {stubForwardBack} from '../utils/stubForwardBack.js'; import {stubVisibilityChange} from '../utils/stubVisibilityChange.js'; +// Temp fix to address Firefox flakiness. +// See https://github.com/GoogleChrome/web-vitals/issues/472 +const originalStrictEqual = assert.strictEqual; +assert.strictEqual = function (actual, expected, message) { + if ( + browser.capabilities.browserName === 'firefox' && + (expected === 'good' || expected === 'needs-improvement') && + actual !== expected + ) { + console.error( + `Override assert for Firefox (actual: ${actual}, expected: ${expected})`, + ); + return true; + } + return originalStrictEqual(actual, expected, message); +}; + describe('onLCP()', async function () { // Retry all tests in this suite up to 2 times. this.retries(2); @@ -690,11 +707,7 @@ const assertStandardReportsAreCorrect = (beacons) => { assert(lcp.id.match(/^v4-\d+-\d+$/)); assert.strictEqual(lcp.name, 'LCP'); assert.strictEqual(lcp.value, lcp.delta); - // Temp fix to address Firefox flakiness. - // See https://github.com/GoogleChrome/web-vitals/issues/472 - if (browser.capabilities.browserName !== 'firefox') { - assert.strictEqual(lcp.rating, 'good'); - } + assert.strictEqual(lcp.rating, 'good'); assert.strictEqual(lcp.entries.length, 1); assert.match(lcp.navigationType, /navigate|reload/); };