Skip to content

Commit 6d0bce9

Browse files
authored
fix(tests): Make CLS web vital test less flaky (#4490)
Despite the fact that we're using a `toBeCloseTo()` check rather than a `toEqual()` check on the integration test for recording a "poor" CLS web vital, that test seems to have a habit of failing in CI, by ending up being not quite close enough to the desired value. This fixes that by widening the window of tolerance just slightly, hopefully enough to prevent the flakiness.
1 parent 3fe2218 commit 6d0bce9

File tree

1 file changed

+7
-1
lines changed
  • packages/integration-tests/suites/tracing/metrics/web-vitals-cls

1 file changed

+7
-1
lines changed

packages/integration-tests/suites/tracing/metrics/web-vitals-cls/test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ sentryTest('should capture a "POOR" CLS vital with its source(s).', async ({ get
3737

3838
expect(eventData.measurements).toBeDefined();
3939
expect(eventData.measurements?.cls?.value).toBeDefined();
40-
expect(eventData.measurements?.cls?.value).toBeCloseTo(0.35);
40+
// This test in particular seems to be flaky, such that the received value is frequently within 0.006 rather than the
41+
// 0.005 that `toBeCloseTo()` requires. While it's true that each test is retried twice if it fails, in the flaky
42+
// cases all three attempts always seem to come up with the exact same slightly-too-far-away number. Rather than ramp
43+
// down `toBeCloseTo()`'s precision (which would make it accept anything between 0.30 and 0.40), we can just do the
44+
// check manually.
45+
expect(eventData.measurements?.cls?.value).toBeGreaterThan(0.34);
46+
expect(eventData.measurements?.cls?.value).toBeLessThan(0.36);
4147
expect(eventData.tags?.['cls.source.1']).toBe('body > div#content > p');
4248
});

0 commit comments

Comments
 (0)