diff --git a/dev-packages/e2e-tests/test-applications/remix-hydrogen/tests/client-transactions.test.ts b/dev-packages/e2e-tests/test-applications/remix-hydrogen/tests/client-transactions.test.ts index 4d0fa8f92bdc..549383810633 100644 --- a/dev-packages/e2e-tests/test-applications/remix-hydrogen/tests/client-transactions.test.ts +++ b/dev-packages/e2e-tests/test-applications/remix-hydrogen/tests/client-transactions.test.ts @@ -14,12 +14,23 @@ test('Sends a pageload transaction to Sentry', async ({ page }) => { }); test('Sends a navigation transaction to Sentry', async ({ page }) => { + // Wait for the initial pageload transaction first. This ensures the client SDK and + // Remix router are fully hydrated before we click the link. Clicking before hydration + // completes makes the `` behave like a plain anchor, triggering a full page + // navigation (a `pageload` transaction) instead of a client-side `navigation` one, + // which makes this test flaky. + const pageloadTransactionPromise = waitForTransaction('remix-hydrogen', transactionEvent => { + return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === '/'; + }); + const transactionPromise = waitForTransaction('remix-hydrogen', transactionEvent => { return transactionEvent.contexts?.trace?.op === 'navigation' && transactionEvent.transaction === '/user/:id'; }); await page.goto('/'); + await pageloadTransactionPromise; + const linkElement = page.locator('id=navigation'); await linkElement.click();