File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
dev-packages/browser-integration-tests/suites/sessions/initial-scope Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import type { Route } from '@playwright/test';
22import { expect } from '@playwright/test' ;
33import type { SessionContext } from '@sentry/core' ;
44import { sentryTest } from '../../../utils/fixtures' ;
5- import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers' ;
5+ import { getFirstSentryEnvelopeRequest , waitForSession } from '../../../utils/helpers' ;
66
77sentryTest ( 'should start a new session on pageload.' , async ( { getLocalTestUrl, page } ) => {
88 const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
@@ -22,9 +22,12 @@ sentryTest('should start a new session with navigation.', async ({ getLocalTestU
2222
2323 const initSession = await getFirstSentryEnvelopeRequest < SessionContext > ( page , url ) ;
2424
25+ // Set up session listener BEFORE clicking to avoid race condition
26+ // between the click-triggered navigation and a second page.goto() call
27+ const newSessionPromise = waitForSession ( page ) ;
2528 await page . click ( '#navigate' ) ;
2629
27- const newSession = await getFirstSentryEnvelopeRequest < SessionContext > ( page , url ) ;
30+ const newSession = await newSessionPromise ;
2831
2932 expect ( newSession ) . toBeDefined ( ) ;
3033 expect ( newSession . init ) . toBe ( true ) ;
You can’t perform that action at this time.
0 commit comments