:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(experiments): freeze clock in metricQueryUtils getQuery tests (#70244)
Paul D'Ambradd4eae118960
diff --git a/frontend/src/scenes/experiments/metricQueryUtils.test.ts b/frontend/src/scenes/experiments/metricQueryUtils.test.tsindex 15856fe07d80..2184c55ef01a 100644--- a/frontend/src/scenes/experiments/metricQueryUtils.test.ts+++ b/frontend/src/scenes/experiments/metricQueryUtils.test.ts@@ -26,6 +26,18 @@ import {getQuery,} from './metricQueryUtils'+// getQuery builds date_from/date_to from dayjs() at call time, formatted to the minute.+// The expected values below recompute dayjs() independently, so a minute rollover between+// the two reads makes the strings differ and toEqual flakes. Freeze the clock (no+// advanceTimers, so it cannot move) to make both reads resolve to the same instant.+beforeAll(() => {+ jest.useFakeTimers().setSystemTime(new Date('2026-01-15T12:00:00'))+})++afterAll(() => {+ jest.useRealTimers()+})+describe('getFilter', () => {it('returns the correct filter for an event', () => {const metric: ExperimentMetric = {