@@ -3,37 +3,40 @@ import { expect } from '@playwright/test';
33import { sentryTest } from '../../../../utils/fixtures' ;
44import { getReplaySnapshot , shouldSkipReplayTest , waitForReplayRequest } from '../../../../utils/replayHelpers' ;
55
6- sentryTest ( '[error-mode] should handle errors with custom transport' , async ( { getLocalTestPath, page } ) => {
7- if ( shouldSkipReplayTest ( ) ) {
8- sentryTest . skip ( ) ;
9- }
6+ sentryTest (
7+ '[error-mode] should handle errors with custom transport' ,
8+ async ( { getLocalTestPath, page, forceFlushReplay } ) => {
9+ if ( shouldSkipReplayTest ( ) ) {
10+ sentryTest . skip ( ) ;
11+ }
1012
11- const promiseReq0 = waitForReplayRequest ( page , 0 ) ;
12- const promiseReq1 = waitForReplayRequest ( page , 1 ) ;
13+ const promiseReq0 = waitForReplayRequest ( page , 0 ) ;
14+ const promiseReq1 = waitForReplayRequest ( page , 1 ) ;
1315
14- let callsToSentry = 0 ;
16+ let callsToSentry = 0 ;
1517
16- await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
17- callsToSentry ++ ;
18+ await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
19+ callsToSentry ++ ;
1820
19- return route . fulfill ( {
20- // Only error out for error, then succeed
21- status : callsToSentry === 1 ? 422 : 200 ,
21+ return route . fulfill ( {
22+ // Only error out for error, then succeed
23+ status : callsToSentry === 1 ? 422 : 200 ,
24+ } ) ;
2225 } ) ;
23- } ) ;
2426
25- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
27+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
2628
27- await page . goto ( url ) ;
28- await page . click ( '#go-background' ) ;
29- expect ( callsToSentry ) . toEqual ( 0 ) ;
29+ await page . goto ( url ) ;
30+ await forceFlushReplay ( ) ;
31+ expect ( callsToSentry ) . toEqual ( 0 ) ;
3032
31- await page . click ( '#error' ) ;
32- await promiseReq0 ;
33+ await page . click ( '#error' ) ;
34+ await promiseReq0 ;
3335
34- await page . click ( '#go-background' ) ;
35- await promiseReq1 ;
36+ await forceFlushReplay ( ) ;
37+ await promiseReq1 ;
3638
37- const replay = await getReplaySnapshot ( page ) ;
38- expect ( replay . recordingMode ) . toBe ( 'session' ) ;
39- } ) ;
39+ const replay = await getReplaySnapshot ( page ) ;
40+ expect ( replay . recordingMode ) . toBe ( 'session' ) ;
41+ } ,
42+ ) ;
0 commit comments