From 9c21489ae710bfeacd9a01d29cd8c02abceda6f8 Mon Sep 17 00:00:00 2001 From: PJ Date: Sat, 22 Aug 2026 21:41:40 +0530 Subject: [PATCH] test(chrome): pin that Metrics reports no CPU sample rather than a zero --- internal/driver/chrome/driver_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/driver/chrome/driver_test.go b/internal/driver/chrome/driver_test.go index f54d5a4..8863e43 100644 --- a/internal/driver/chrome/driver_test.go +++ b/internal/driver/chrome/driver_test.go @@ -1233,3 +1233,19 @@ func TestMetrics_AFailedRoundTripIsNotAPageWithoutTheAPI(t *testing.T) { "the run cannot tell that from a page with no performance.memory", metrics) } } + +// CDP exposes no per-page CPU, so every web step used to record a zero the +// sampler never took, which is the same answer an idle app gives. +func TestMetrics_ReportsNoCPUSampleRatherThanZero(t *testing.T) { + server := servePage(t, `
app
`) + d, ctx := launchChrome(t, server.URL) + + metrics, err := d.Metrics(ctx, "") + if err != nil { + t.Fatalf("Metrics: %v", err) + } + if metrics.CPUPercent != nil { + t.Errorf("Metrics reported CPUPercent %v; chrome samples no CPU, and a "+ + "run cannot tell that reading from an app using none", *metrics.CPUPercent) + } +}