Skip to content

: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.

fix(test): wrap goal line assertions in waitFor to fix flake (#65183)

mendral-app[bot]cc79f8d83a19
diff --git a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx
index 7ce020403a9f..1374a556dada 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx
+++ b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx
@@ -624,9 +624,14 @@ describe('TrendsBarChart overlays', () => {
})
await screen.findByRole('img', { name: /chart with/i }, { timeout: 5000 })
- const lines = getHogChart().referenceLines()
- expect(lines.map((l) => l.label)).toEqual(['Target'])
- expect(lines[0].orientation).toBe(expectedOrientation)
+ await waitFor(
+ () => {
+ const lines = getHogChart().referenceLines()
+ expect(lines.map((l) => l.label)).toEqual(['Target'])
+ expect(lines[0].orientation).toBe(expectedOrientation)
+ },
+ { timeout: 5000 }
+ )
}
)
})