From 2c95c9416bcb57d8be2e14235054884c8fd909f5 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:44:31 -0600 Subject: [PATCH] fix: serverTiming duration testing is robust across platforms --- packages/verified-fetch/test/utils/server-timing.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/verified-fetch/test/utils/server-timing.spec.ts b/packages/verified-fetch/test/utils/server-timing.spec.ts index 48abae2..b681661 100644 --- a/packages/verified-fetch/test/utils/server-timing.spec.ts +++ b/packages/verified-fetch/test/utils/server-timing.spec.ts @@ -61,6 +61,7 @@ describe('serverTiming', () => { const [, timingDuration] = result.header.split(';') const durationValue = Number(timingDuration.replace('dur=', '')) - expect(durationValue).to.be.greaterThan(20).and.lessThan(30) + // round durationValue to nearest 10ms. On windows and firefox, a delay of 20ms returns ~19.x ms + expect(Math.ceil(durationValue / 10) * 10).to.be.greaterThanOrEqual(20).and.lessThanOrEqual(30) }) })