@@ -4,62 +4,66 @@ import { sentryTest } from '../../../../../utils/fixtures';
44import { envelopeRequestParser , waitForErrorRequest } from '../../../../../utils/helpers' ;
55import { shouldSkipReplayTest } from '../../../../../utils/replayHelpers' ;
66
7- sentryTest ( 'parses response_body_size from Content-Length header if available' , async ( { getLocalTestPath, page } ) => {
8- if ( shouldSkipReplayTest ( ) ) {
9- sentryTest . skip ( ) ;
10- }
7+ sentryTest (
8+ 'parses response_body_size from Content-Length header if available' ,
9+ async ( { getLocalTestPath, page, browserName } ) => {
10+ // These are a bit flaky on non-chromium browsers
11+ if ( shouldSkipReplayTest ( ) || browserName !== 'chromium' ) {
12+ sentryTest . skip ( ) ;
13+ }
1114
12- await page . route ( '**/foo' , route => {
13- return route . fulfill ( {
14- status : 200 ,
15- body : JSON . stringify ( {
16- userNames : [ 'John' , 'Jane' ] ,
17- } ) ,
18- headers : {
19- 'Content-Type' : 'application/json' ,
20- 'Content-Length' : '789' ,
21- } ,
15+ await page . route ( '**/foo' , route => {
16+ return route . fulfill ( {
17+ status : 200 ,
18+ body : JSON . stringify ( {
19+ userNames : [ 'John' , 'Jane' ] ,
20+ } ) ,
21+ headers : {
22+ 'Content-Type' : 'application/json' ,
23+ 'Content-Length' : '789' ,
24+ } ,
25+ } ) ;
2226 } ) ;
23- } ) ;
2427
25- const requestPromise = waitForErrorRequest ( page ) ;
26- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
27- await page . goto ( url ) ;
28+ const requestPromise = waitForErrorRequest ( page ) ;
29+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
30+ await page . goto ( url ) ;
2831
29- await page . evaluate ( ( ) => {
30- /* eslint-disable */
31- const xhr = new XMLHttpRequest ( ) ;
32+ await page . evaluate ( ( ) => {
33+ /* eslint-disable */
34+ const xhr = new XMLHttpRequest ( ) ;
3235
33- xhr . open ( 'GET' , 'http://localhost:7654/foo' ) ;
34- xhr . setRequestHeader ( 'Accept' , 'application/json' ) ;
35- xhr . setRequestHeader ( 'Content-Type' , 'application/json' ) ;
36- xhr . setRequestHeader ( 'Cache' , 'no-cache' ) ;
37- xhr . send ( ) ;
36+ xhr . open ( 'GET' , 'http://localhost:7654/foo' ) ;
37+ xhr . setRequestHeader ( 'Accept' , 'application/json' ) ;
38+ xhr . setRequestHeader ( 'Content-Type' , 'application/json' ) ;
39+ xhr . setRequestHeader ( 'Cache' , 'no-cache' ) ;
40+ xhr . send ( ) ;
3841
39- xhr . addEventListener ( 'readystatechange' , function ( ) {
40- if ( xhr . readyState === 4 ) {
41- // @ts -ignore Sentry is a global
42- setTimeout ( ( ) => Sentry . captureException ( 'test error' , 0 ) ) ;
43- }
42+ xhr . addEventListener ( 'readystatechange' , function ( ) {
43+ if ( xhr . readyState === 4 ) {
44+ // @ts -ignore Sentry is a global
45+ setTimeout ( ( ) => Sentry . captureException ( 'test error' , 0 ) ) ;
46+ }
47+ } ) ;
48+ /* eslint-enable */
4449 } ) ;
45- /* eslint-enable */
46- } ) ;
4750
48- const request = await requestPromise ;
49- const eventData = envelopeRequestParser ( request ) ;
51+ const request = await requestPromise ;
52+ const eventData = envelopeRequestParser ( request ) ;
5053
51- expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
54+ expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
5255
53- expect ( eventData ?. breadcrumbs ?. length ) . toBe ( 1 ) ;
54- expect ( eventData ! . breadcrumbs ! [ 0 ] ) . toEqual ( {
55- timestamp : expect . any ( Number ) ,
56- category : 'xhr' ,
57- type : 'http' ,
58- data : {
59- method : 'GET' ,
60- response_body_size : 789 ,
61- status_code : 200 ,
62- url : 'http://localhost:7654/foo' ,
63- } ,
64- } ) ;
65- } ) ;
56+ expect ( eventData ?. breadcrumbs ?. length ) . toBe ( 1 ) ;
57+ expect ( eventData ! . breadcrumbs ! [ 0 ] ) . toEqual ( {
58+ timestamp : expect . any ( Number ) ,
59+ category : 'xhr' ,
60+ type : 'http' ,
61+ data : {
62+ method : 'GET' ,
63+ response_body_size : 789 ,
64+ status_code : 200 ,
65+ url : 'http://localhost:7654/foo' ,
66+ } ,
67+ } ) ;
68+ } ,
69+ ) ;
0 commit comments