Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better alternative for test flakiness on Firefox for FCP and LCP #476

Merged
merged 6 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions test/e2e/onFCP-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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/);

Expand All @@ -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');

Expand All @@ -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');
});
Expand Down
23 changes: 18 additions & 5 deletions test/e2e/onLCP-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -680,11 +697,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/);
};
Expand Down