: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(customer-analytics): raise jest timeout for expanded-row stories (#73046)
Daniel Visca3c3db2ea3db2
diff --git a/common/storybook/.storybook/test-runner.ts b/common/storybook/.storybook/test-runner.tsindex 519ef1041cdc..c070de96a1b4 100644--- a/common/storybook/.storybook/test-runner.ts+++ b/common/storybook/.storybook/test-runner.ts@@ -41,6 +41,12 @@ declare module 'storybook/internal/types' {waitForSelector?: string | string[]/** Timeout in ms for waitForSelector. Defaults to Playwright's context timeout (PLAYWRIGHT_TIMEOUT_MS). */waitForSelectorTimeout?: number+ /**+ * Override the per-test Jest timeout (ms) for stories whose render legitimately needs+ * longer than the default. Use sparingly — a slow story is usually a bug, not a budget+ * problem. Still scaled by the viewport-widths multiplier. Defaults to JEST_TIMEOUT_MS.+ */+ jestTimeout?: number/*** By default we wait for images to have width as an indication the page is ready for screenshot testing* Some stories have broken images on purpose to test what the UI does@@ -142,8 +148,8 @@ export default {route.fulfill({ status: 200, contentType: 'text/html', body: EMBED_STUB_HTML }))const storyContext = await getStoryContext(page, context)- const { viewport, viewportWidths } = storyContext.parameters?.testOptions ?? {}- applyStoryTimeouts(page, viewportWidths)+ const { viewport, viewportWidths, jestTimeout } = storyContext.parameters?.testOptions ?? {}+ applyStoryTimeouts(page, viewportWidths, jestTimeout)const effectiveViewport = viewportWidths?.length? VIEWPORT_WIDTHS[viewportWidths[0]]: viewport || DEFAULT_VIEWPORT@@ -153,7 +159,7 @@ export default {async postVisit(page, context) {ATTEMPT_COUNT_PER_ID[context.id] = (ATTEMPT_COUNT_PER_ID[context.id] || 0) + 1const storyContext = await getStoryContext(page, context)- const { viewport, viewportWidths } = storyContext.parameters?.testOptions ?? {}+ const { viewport, viewportWidths, jestTimeout } = storyContext.parameters?.testOptions ?? {}const effectiveViewport = viewportWidths?.length? VIEWPORT_WIDTHS[viewportWidths[0]]: viewport || DEFAULT_VIEWPORT@@ -175,7 +181,7 @@ export default {const { snapshotBrowsers = ['chromium'] } = storyContext.parameters?.testOptions ?? {}// Keep timeouts scaled in postVisit too, as retries can run through this path multiple times.- applyStoryTimeouts(page, viewportWidths)+ applyStoryTimeouts(page, viewportWidths, jestTimeout)const currentBrowser = browserContext.browser()!.browserType().name() as SupportedBrowserNameif (snapshotBrowsers.includes(currentBrowser)) {if (viewportWidths?.length) {@@ -576,10 +582,10 @@ async function waitForPageReady(page: Page, skipNetworkIdle = false): Promise<vo.catch(() => undefined)}-function applyStoryTimeouts(page: Page, viewportWidths?: ViewportWidthName[]): void {+function applyStoryTimeouts(page: Page, viewportWidths?: ViewportWidthName[], jestTimeout?: number): void {// Multi-width stories effectively run several snapshots inside one smoke test.const timeoutMultiplier = viewportWidths?.length || 1- jest.setTimeout(JEST_TIMEOUT_MS * timeoutMultiplier)+ jest.setTimeout((jestTimeout ?? JEST_TIMEOUT_MS) * timeoutMultiplier)page.context().setDefaultTimeout(PLAYWRIGHT_TIMEOUT_MS * timeoutMultiplier)}diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsxindex f46cf018a313..7f3ca81725dc 100644--- a/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx@@ -139,9 +139,14 @@ async function expandAndOpenTab(canvasElement: HTMLElement, tab: 'Usage' | 'Spen// The snapshot fires well after `play` (page-ready waits, forced reflows, a dispatched resize),// and the meta-level waitForSelector is satisfied by a collapsed table. Gating the snapshot on the// expanded-row content turns a lost expansion into a retry instead of a flaky collapsed capture.+// The 60s waitForSelector can eat the whole default 60s Jest budget on its own, leaving no room+// for the surrounding page-ready waits, reflows, and the two theme snapshots — so under CI load+// the test hits the Jest timeout even when the expansion eventually renders. Give it a 120s Jest+// budget so the selector wait has headroom instead of racing the test timeout.const EXPANDED_ROW_TEST_OPTIONS = {waitForSelector: ['[data-attr="accounts-refresh"]', '[data-attr="account-expansion"]'],waitForSelectorTimeout: 60000,+ jestTimeout: 120000,}function mockAccountsQuery(rows: AccountRow[]): (info: MockResolverInfo) => Promise<[number, unknown] | undefined> {