From a1bb1dd94f12b252e6995898998594811f495772 Mon Sep 17 00:00:00 2001 From: Ross Wollman Date: Wed, 14 Dec 2022 18:24:54 -0500 Subject: [PATCH] test: fix flaky cookie roundtrip test (#19459) Screenshot 2022-12-14 at 2 05 29 PM Flakiness dashboard reveals on Window's variants of Chromium, the decimal for actual vs. expected was slightly off (e.g. 1705568002.677066 vs. 1705568002.674173). This test fix assumes it's acceptable to suppress the roundtrip floating point difference (which appears to be constrained to Windows). Signed-off-by: Ross Wollman --- tests/library/browsercontext-add-cookies.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/library/browsercontext-add-cookies.spec.ts b/tests/library/browsercontext-add-cookies.spec.ts index 549bf8f148..b91b133276 100644 --- a/tests/library/browsercontext-add-cookies.spec.ts +++ b/tests/library/browsercontext-add-cookies.spec.ts @@ -15,6 +15,7 @@ * limitations under the License. */ +import type { Cookie } from '@playwright/test'; import { contextTest as it, playwrightTest, expect } from '../config/browserTest'; it('should work @smoke', async ({ context, page, server }) => { @@ -77,7 +78,9 @@ it('should roundtrip cookie', async ({ context, page, server }) => { await context.clearCookies(); expect(await context.cookies()).toEqual([]); await context.addCookies(cookies); - expect(await context.cookies()).toEqual(cookies); + // Slightly different rounding on chromium win. + const normalizedExpires = (cookies: Cookie[]) => cookies.map(c => ({ ...c, expires: Math.floor(c.expires) })); + expect(normalizedExpires(await context.cookies())).toEqual(normalizedExpires(cookies)); }); it('should send cookie header', async ({ server, context }) => {