From 5b91b766031c435e44dda912be75f685d77fe073 Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Sun, 4 Aug 2024 08:54:30 +0100 Subject: [PATCH] Improve test flakiness (#507) * Remove firefox workarounds for test flakiness * Add extra wait to hidden test * Skip prerender tests if unsupported * Oops, forgot to include the new file * Urgh I should just test this first * Refactor * Skip prerender on all metrics if not supported * Alternative LCP hidden flakiness fix * Another anti-flaky test * Check * Update to complete * Fix for Safari * Add comment * Another Safari fix * Try Phil's fix * Revert fix * Remove 100ms delay * Add Safari to navigateTo workaround * Remove debugging logging * Revert Safari change * Try another fix * Check both * Fix it * Restrict to Safari and Firefox * Remove debugging logging * Wait for interactive for flakey INP test * Temporarily disable prerender support check * Remove the prerender skips in tests --------- Co-authored-by: Philip Walton --- test/e2e/onFCP-test.js | 20 +------------------- test/e2e/onINP-test.js | 6 +++++- test/e2e/onLCP-test.js | 36 ++++-------------------------------- test/utils/navigateTo.js | 19 +++++++++++++------ wdio.conf.cjs | 2 ++ 5 files changed, 25 insertions(+), 58 deletions(-) diff --git a/test/e2e/onFCP-test.js b/test/e2e/onFCP-test.js index ce0de79c..d7748136 100644 --- a/test/e2e/onFCP-test.js +++ b/test/e2e/onFCP-test.js @@ -21,24 +21,6 @@ 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 ( - process.env.GITHUB_ACTIONS && - 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); @@ -134,7 +116,7 @@ describe('onFCP()', async function () { it('does not report if the document was hidden at page load time', async function () { if (!browserSupportsFCP) this.skip(); - await navigateTo('/test/fcp?hidden=1', {readyState: 'interactive'}); + await navigateTo('/test/fcp?hidden=1', {readyState: 'complete'}); await stubVisibilityChange('visible'); diff --git a/test/e2e/onINP-test.js b/test/e2e/onINP-test.js index 3bdc691b..4db92e47 100644 --- a/test/e2e/onINP-test.js +++ b/test/e2e/onINP-test.js @@ -699,12 +699,16 @@ describe('onINP()', async function () { it('includes LoAF entries if the browser supports it', async function () { if (!browserSupportsLoAF) this.skip(); - await navigateTo('/test/inp?attribution=1&pointerdown=100'); + await navigateTo('/test/inp?attribution=1&pointerdown=100', { + readyState: 'interactive', + }); // Click on the