@@ -17,49 +17,54 @@ import { getReplayEvent, shouldSkipReplayTest, waitForReplayRequest } from '../.
1717 * TODO: Once we have lifecycle hooks, we should revisit this test and make sure it behaves as expected.
1818 * This means that the recording should not be started or stopped if the error that triggered it is not sent.
1919 */
20- sentryTest (
21- '[error-mode] should start recording if an error occurred although the error was dropped' ,
22- async ( { getLocalTestPath, page } ) => {
23- if ( shouldSkipReplayTest ( ) ) {
24- sentryTest . skip ( ) ;
25- }
20+ for ( let i = 0 ; i < 100 ; i ++ ) {
21+ sentryTest (
22+ `[error-mode] should start recording if an error occurred although the error was dropped RUN ${ i } ` ,
23+ async ( { getLocalTestPath, page } ) => {
24+ if ( shouldSkipReplayTest ( ) ) {
25+ sentryTest . skip ( ) ;
26+ }
2627
27- let callsToSentry = 0 ;
28- const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
28+ let callsToSentry = 0 ;
29+ const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
30+ const reqPromise1 = waitForReplayRequest ( page , 1 ) ;
2931
30- await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
31- callsToSentry ++ ;
32- return route . fulfill ( {
33- status : 200 ,
34- contentType : 'application/json' ,
35- body : JSON . stringify ( { id : 'test-id' } ) ,
32+ await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
33+ callsToSentry ++ ;
34+ return route . fulfill ( {
35+ status : 200 ,
36+ contentType : 'application/json' ,
37+ body : JSON . stringify ( { id : 'test-id' } ) ,
38+ } ) ;
3639 } ) ;
37- } ) ;
3840
39- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
41+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
4042
41- await page . goto ( url ) ;
42- await page . click ( '#go-background' ) ;
43- expect ( callsToSentry ) . toEqual ( 0 ) ;
43+ await page . goto ( url ) ;
44+ await page . click ( '#go-background' ) ;
45+ expect ( callsToSentry ) . toEqual ( 0 ) ;
4446
45- await page . click ( '#error' ) ;
46- const req0 = await reqPromise0 ;
47+ await page . click ( '#error' ) ;
48+ const req0 = await reqPromise0 ;
4749
48- await page . click ( '#go-background' ) ;
49- expect ( callsToSentry ) . toEqual ( 2 ) ; // 2 replay events
50+ await page . click ( '#go-background' ) ;
51+ await reqPromise1 ;
5052
51- await page . click ( '#log' ) ;
52- await page . click ( '#go-background' ) ;
53+ expect ( callsToSentry ) . toEqual ( 2 ) ; // 2 replay events
5354
54- const event0 = getReplayEvent ( req0 ) ;
55+ await page . click ( '#log' ) ;
56+ await page . click ( '#go-background' ) ;
5557
56- expect ( event0 ) . toEqual (
57- getExpectedReplayEvent ( {
58- contexts : { replay : { error_sample_rate : 1 , session_sample_rate : 0 } } ,
59- // This is by design. A dropped error shouldn't be in this list.
60- error_ids : [ ] ,
61- replay_type : 'error' ,
62- } ) ,
63- ) ;
64- } ,
65- ) ;
58+ const event0 = getReplayEvent ( req0 ) ;
59+
60+ expect ( event0 ) . toEqual (
61+ getExpectedReplayEvent ( {
62+ contexts : { replay : { error_sample_rate : 1 , session_sample_rate : 0 } } ,
63+ // This is by design. A dropped error shouldn't be in this list.
64+ error_ids : [ ] ,
65+ replay_type : 'error' ,
66+ } ) ,
67+ ) ;
68+ } ,
69+ ) ;
70+ }
0 commit comments