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 TrendsLineChart goal line assertion in waitFor (#67118)

mendral-app[bot]1481cf6fc718
diff --git a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
index 470a5fcde0fb..a0d3ff3de391 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
+++ b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
@@ -553,11 +553,16 @@ describe('TrendsLineChart', () => {
})
await screen.findByRole('img', { name: /chart with/i })
- const lines = getHogChart().referenceLines()
- expect(lines.map((l) => l.label)).toEqual(expectedLabels)
- for (const line of lines) {
- expect(line.orientation).toBe('horizontal')
- }
+ await waitFor(
+ () => {
+ const lines = getHogChart().referenceLines()
+ expect(lines.map((l) => l.label)).toEqual(expectedLabels)
+ for (const line of lines) {
+ expect(line.orientation).toBe('horizontal')
+ }
+ },
+ { timeout: 5000 }
+ )
})
})