@@ -4,62 +4,66 @@ import { sentryTest } from '../../../../../utils/fixtures';
4
4
import { envelopeRequestParser , waitForErrorRequest } from '../../../../../utils/helpers' ;
5
5
import { shouldSkipReplayTest } from '../../../../../utils/replayHelpers' ;
6
6
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
+ }
11
14
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
+ } ) ;
22
26
} ) ;
23
- } ) ;
24
27
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 ) ;
28
31
29
- await page . evaluate ( ( ) => {
30
- /* eslint-disable */
31
- const xhr = new XMLHttpRequest ( ) ;
32
+ await page . evaluate ( ( ) => {
33
+ /* eslint-disable */
34
+ const xhr = new XMLHttpRequest ( ) ;
32
35
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 ( ) ;
38
41
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 */
44
49
} ) ;
45
- /* eslint-enable */
46
- } ) ;
47
50
48
- const request = await requestPromise ;
49
- const eventData = envelopeRequestParser ( request ) ;
51
+ const request = await requestPromise ;
52
+ const eventData = envelopeRequestParser ( request ) ;
50
53
51
- expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
54
+ expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
52
55
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