@@ -10,138 +10,141 @@ import {
10
10
waitForReplayRequest ,
11
11
} from '../../../../utils/replayHelpers' ;
12
12
13
- sentryTest (
14
- '[session-mode] replay event should contain an error id of an error that occurred during session recording' ,
15
- async ( { getLocalTestPath, page, browserName, forceFlushReplay } ) => {
16
- // TODO(replay): This is flakey on firefox where clicks are flakey
17
- if ( shouldSkipReplayTest ( ) || [ 'firefox' ] . includes ( browserName ) ) {
18
- sentryTest . skip ( ) ;
19
- }
20
-
21
- let errorEventId : string = 'invalid_id' ;
22
-
23
- const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
24
- const reqPromise1 = waitForReplayRequest ( page , 1 ) ;
25
-
26
- await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
27
- const event = envelopeRequestParser ( route . request ( ) ) ;
28
- // error events have no type field
29
- if ( event && ! event . type && event . event_id ) {
30
- errorEventId = event . event_id ;
13
+ for ( let i = 0 ; i < 100 ; i ++ ) {
14
+ sentryTest (
15
+ `[session-mode] replay event should contain an error id of an error that occurred during session recording RUN ${ i } ` ,
16
+ async ( { getLocalTestPath, page, browserName, forceFlushReplay } ) => {
17
+ // TODO(replay): This is flakey on firefox where clicks are flakey
18
+ if ( shouldSkipReplayTest ( ) || browserName === 'firefox' ) {
19
+ sentryTest . skip ( ) ;
31
20
}
32
21
33
- return route . fulfill ( {
34
- status : 200 ,
35
- contentType : 'application/json' ,
36
- body : JSON . stringify ( { id : 'test-id' } ) ,
22
+ let errorEventId : string = 'invalid_id' ;
23
+
24
+ const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
25
+ const reqPromise1 = waitForReplayRequest ( page , 1 ) ;
26
+
27
+ await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
28
+ const event = envelopeRequestParser ( route . request ( ) ) ;
29
+ // error events have no type field
30
+ if ( event && ! event . type && event . event_id ) {
31
+ errorEventId = event . event_id ;
32
+ }
33
+
34
+ return route . fulfill ( {
35
+ status : 200 ,
36
+ contentType : 'application/json' ,
37
+ body : JSON . stringify ( { id : 'test-id' } ) ,
38
+ } ) ;
37
39
} ) ;
38
- } ) ;
39
-
40
- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
41
-
42
- await page . goto ( url ) ;
43
- const req0 = await reqPromise0 ;
44
-
45
- await page . click ( '#error' ) ;
46
- await forceFlushReplay ( ) ;
47
- const req1 = await reqPromise1 ;
48
-
49
- const event0 = getReplayEvent ( req0 ) ;
50
-
51
- const event1 = getReplayEvent ( req1 ) ;
52
- const content1 = getReplayRecordingContent ( req1 ) ;
53
-
54
- expect ( event0 ) . toEqual ( getExpectedReplayEvent ( ) ) ;
55
-
56
- expect ( event1 ) . toEqual (
57
- getExpectedReplayEvent ( {
58
- replay_start_timestamp : undefined ,
59
- segment_id : 1 ,
60
- error_ids : [ errorEventId ] ,
61
- urls : [ ] ,
62
- } ) ,
63
- ) ;
64
-
65
- expect ( content1 . breadcrumbs ) . toEqual (
66
- expect . arrayContaining ( [
67
- {
68
- ...expectedClickBreadcrumb ,
69
- message : 'body > button#error' ,
70
- data : {
71
- node : {
72
- attributes : {
73
- id : 'error' ,
40
+
41
+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
42
+
43
+ await page . goto ( url ) ;
44
+ const req0 = await reqPromise0 ;
45
+
46
+ await page . click ( '#error' ) ;
47
+ await forceFlushReplay ( ) ;
48
+ const req1 = await reqPromise1 ;
49
+
50
+ const event0 = getReplayEvent ( req0 ) ;
51
+
52
+ const event1 = getReplayEvent ( req1 ) ;
53
+ const content1 = getReplayRecordingContent ( req1 ) ;
54
+
55
+ expect ( event0 ) . toEqual ( getExpectedReplayEvent ( ) ) ;
56
+
57
+ expect ( event1 ) . toEqual (
58
+ getExpectedReplayEvent ( {
59
+ replay_start_timestamp : undefined ,
60
+ segment_id : 1 ,
61
+ error_ids : [ errorEventId ] ,
62
+ urls : [ ] ,
63
+ } ) ,
64
+ ) ;
65
+
66
+ expect ( content1 . breadcrumbs ) . toEqual (
67
+ expect . arrayContaining ( [
68
+ {
69
+ ...expectedClickBreadcrumb ,
70
+ message : 'body > button#error' ,
71
+ data : {
72
+ node : {
73
+ attributes : {
74
+ id : 'error' ,
75
+ } ,
76
+ id : expect . any ( Number ) ,
77
+ tagName : 'button' ,
78
+ textContent : '***** *****' ,
74
79
} ,
75
- id : expect . any ( Number ) ,
76
- tagName : 'button' ,
77
- textContent : '***** *****' ,
80
+ nodeId : expect . any ( Number ) ,
78
81
} ,
79
- nodeId : expect . any ( Number ) ,
80
82
} ,
81
- } ,
82
- ] ) ,
83
- ) ;
84
- } ,
85
- ) ;
86
-
87
- sentryTest (
88
- '[session-mode] replay event should not contain an error id of a dropped error while recording' ,
89
- async ( { getLocalTestPath, page, forceFlushReplay } ) => {
90
- if ( shouldSkipReplayTest ( ) ) {
91
- sentryTest . skip ( ) ;
92
- }
93
-
94
- const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
95
- const reqPromise1 = waitForReplayRequest ( page , 1 ) ;
96
-
97
- await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
98
- return route . fulfill ( {
99
- status : 200 ,
100
- contentType : 'application/json' ,
101
- body : JSON . stringify ( { id : 'test-id' } ) ,
83
+ ] ) ,
84
+ ) ;
85
+ } ,
86
+ ) ;
87
+
88
+ sentryTest (
89
+ `[session-mode] replay event should not contain an error id of a dropped error while recording RUN ${ i } ` ,
90
+ async ( { getLocalTestPath, page, forceFlushReplay, browserName } ) => {
91
+ // TODO(replay): This is flakey on firefox where clicks are flakey
92
+ if ( shouldSkipReplayTest ( ) || browserName === 'firefox' ) {
93
+ sentryTest . skip ( ) ;
94
+ }
95
+
96
+ const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
97
+ const reqPromise1 = waitForReplayRequest ( page , 1 ) ;
98
+
99
+ await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
100
+ return route . fulfill ( {
101
+ status : 200 ,
102
+ contentType : 'application/json' ,
103
+ body : JSON . stringify ( { id : 'test-id' } ) ,
104
+ } ) ;
102
105
} ) ;
103
- } ) ;
104
-
105
- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
106
-
107
- await page . goto ( url ) ;
108
- await reqPromise0 ;
109
-
110
- await page . click ( '#drop' ) ;
111
- await forceFlushReplay ( ) ;
112
- const req1 = await reqPromise1 ;
113
-
114
- const event1 = getReplayEvent ( req1 ) ;
115
- const content1 = getReplayRecordingContent ( req1 ) ;
116
-
117
- expect ( event1 ) . toEqual (
118
- getExpectedReplayEvent ( {
119
- replay_start_timestamp : undefined ,
120
- segment_id : 1 ,
121
- error_ids : [ ] , // <-- no error id
122
- urls : [ ] ,
123
- } ) ,
124
- ) ;
125
-
126
- // The button click that triggered the error should still be recorded
127
- expect ( content1 . breadcrumbs ) . toEqual (
128
- expect . arrayContaining ( [
129
- {
130
- ...expectedClickBreadcrumb ,
131
- message : 'body > button#drop' ,
132
- data : {
133
- node : {
134
- attributes : {
135
- id : 'drop' ,
106
+
107
+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
108
+
109
+ await page . goto ( url ) ;
110
+ await reqPromise0 ;
111
+
112
+ await page . click ( '#drop' ) ;
113
+ await forceFlushReplay ( ) ;
114
+ const req1 = await reqPromise1 ;
115
+
116
+ const event1 = getReplayEvent ( req1 ) ;
117
+ const content1 = getReplayRecordingContent ( req1 ) ;
118
+
119
+ expect ( event1 ) . toEqual (
120
+ getExpectedReplayEvent ( {
121
+ replay_start_timestamp : undefined ,
122
+ segment_id : 1 ,
123
+ error_ids : [ ] , // <-- no error id
124
+ urls : [ ] ,
125
+ } ) ,
126
+ ) ;
127
+
128
+ // The button click that triggered the error should still be recorded
129
+ expect ( content1 . breadcrumbs ) . toEqual (
130
+ expect . arrayContaining ( [
131
+ {
132
+ ...expectedClickBreadcrumb ,
133
+ message : 'body > button#drop' ,
134
+ data : {
135
+ node : {
136
+ attributes : {
137
+ id : 'drop' ,
138
+ } ,
139
+ id : expect . any ( Number ) ,
140
+ tagName : 'button' ,
141
+ textContent : '***** ***** *** **** **' ,
136
142
} ,
137
- id : expect . any ( Number ) ,
138
- tagName : 'button' ,
139
- textContent : '***** ***** *** **** **' ,
143
+ nodeId : expect . any ( Number ) ,
140
144
} ,
141
- nodeId : expect . any ( Number ) ,
142
145
} ,
143
- } ,
144
- ] ) ,
145
- ) ;
146
- } ,
147
- ) ;
146
+ ] ) ,
147
+ ) ;
148
+ } ,
149
+ ) ;
150
+ }
0 commit comments