@@ -12,15 +12,14 @@ describe('getTraceMetaTags', () => {
12
12
13
13
const runner = createRunner ( __dirname , 'server.js' ) . start ( ) ;
14
14
15
- const response = await runner . makeRequest ( 'get' , '/test' , {
15
+ const response = await runner . makeRequest < { response : string } > ( 'get' , '/test' , {
16
16
headers : {
17
17
'sentry-trace' : `${ traceId } -${ parentSpanId } -1` ,
18
18
baggage : 'sentry-environment=production,sentry-sample_rand=0.42' ,
19
19
} ,
20
20
} ) ;
21
21
22
- // @ts -ignore - response is defined, types just don't reflect it
23
- const html = response ?. response as unknown as string ;
22
+ const html = response ?. response ;
24
23
25
24
expect ( html ) . toMatch ( / < m e t a n a m e = " s e n t r y - t r a c e " c o n t e n t = " c d 7 e e 7 a 6 f e 3 e b e 7 a b 9 c 3 2 7 1 5 5 9 b c 2 0 3 c - [ a - z 0 - 9 ] { 16 } - 1 " \/ > / ) ;
26
25
expect ( html ) . toContain ( '<meta name="baggage" content="sentry-environment=production,sentry-sample_rand=0.42"/>' ) ;
@@ -29,12 +28,11 @@ describe('getTraceMetaTags', () => {
29
28
test ( 'injects <meta> tags with new trace if no incoming headers' , async ( ) => {
30
29
const runner = createRunner ( __dirname , 'server.js' ) . start ( ) ;
31
30
32
- const response = await runner . makeRequest ( 'get' , '/test' ) ;
31
+ const response = await runner . makeRequest < { response : string } > ( 'get' , '/test' ) ;
33
32
34
- // @ts -ignore - response is defined, types just don't reflect it
35
- const html = response ?. response as unknown as string ;
33
+ const html = response ?. response ;
36
34
37
- const traceId = html . match ( / < m e t a n a m e = " s e n t r y - t r a c e " c o n t e n t = " ( [ a - z 0 - 9 ] { 32 } ) - [ a - z 0 - 9 ] { 16 } - 1 " \/ > / ) ?. [ 1 ] ;
35
+ const traceId = html ? .match ( / < m e t a n a m e = " s e n t r y - t r a c e " c o n t e n t = " ( [ a - z 0 - 9 ] { 32 } ) - [ a - z 0 - 9 ] { 16 } - 1 " \/ > / ) ?. [ 1 ] ;
38
36
expect ( traceId ) . not . toBeUndefined ( ) ;
39
37
40
38
expect ( html ) . toContain ( '<meta name="baggage"' ) ;
@@ -44,12 +42,11 @@ describe('getTraceMetaTags', () => {
44
42
test ( 'injects <meta> tags with negative sampling decision if tracesSampleRate is 0' , async ( ) => {
45
43
const runner = createRunner ( __dirname , 'server-tracesSampleRate-zero.js' ) . start ( ) ;
46
44
47
- const response = await runner . makeRequest ( 'get' , '/test' ) ;
45
+ const response = await runner . makeRequest < { response : string } > ( 'get' , '/test' ) ;
48
46
49
- // @ts -ignore - response is defined, types just don't reflect it
50
- const html = response ?. response as unknown as string ;
47
+ const html = response ?. response ;
51
48
52
- const traceId = html . match ( / < m e t a n a m e = " s e n t r y - t r a c e " c o n t e n t = " ( [ a - z 0 - 9 ] { 32 } ) - [ a - z 0 - 9 ] { 16 } - 0 " \/ > / ) ?. [ 1 ] ;
49
+ const traceId = html ? .match ( / < m e t a n a m e = " s e n t r y - t r a c e " c o n t e n t = " ( [ a - z 0 - 9 ] { 32 } ) - [ a - z 0 - 9 ] { 16 } - 0 " \/ > / ) ?. [ 1 ] ;
53
50
expect ( traceId ) . not . toBeUndefined ( ) ;
54
51
55
52
expect ( html ) . toContain ( '<meta name="baggage"' ) ;
@@ -63,15 +60,14 @@ describe('getTraceMetaTags', () => {
63
60
64
61
const runner = createRunner ( __dirname , 'server-sdk-disabled.js' ) . start ( ) ;
65
62
66
- const response = await runner . makeRequest ( 'get' , '/test' , {
63
+ const response = await runner . makeRequest < { response : string } > ( 'get' , '/test' , {
67
64
headers : {
68
65
'sentry-trace' : `${ traceId } -${ parentSpanId } -1` ,
69
66
baggage : 'sentry-environment=production' ,
70
67
} ,
71
68
} ) ;
72
69
73
- // @ts -ignore - response is defined, types just don't reflect it
74
- const html = response ?. response as unknown as string ;
70
+ const html = response ?. response ;
75
71
76
72
expect ( html ) . not . toContain ( '"sentry-trace"' ) ;
77
73
expect ( html ) . not . toContain ( '"baggage"' ) ;
0 commit comments