@@ -15,6 +15,7 @@ import type {
15
15
} from '@sentry/types' ;
16
16
import axios from 'axios' ;
17
17
import { createBasicSentryServer } from './server' ;
18
+ import { normalize } from '@sentry/utils' ;
18
19
19
20
export function assertSentryEvent ( actual : Event , expected : Event ) : void {
20
21
expect ( actual ) . toMatchObject ( {
@@ -130,8 +131,7 @@ async function runDockerCompose(options: DockerOptions): Promise<VoidFunction> {
130
131
function newData ( data : Buffer ) : void {
131
132
const text = data . toString ( 'utf8' ) ;
132
133
133
- // eslint-disable-next-line no-console
134
- if ( process . env . DEBUG ) console . log ( text ) ;
134
+ if ( process . env . DEBUG ) log ( text ) ;
135
135
136
136
for ( const match of options . readyMatches ) {
137
137
if ( text . includes ( match ) ) {
@@ -254,7 +254,7 @@ export function createRunner(...paths: string[]) {
254
254
255
255
function complete ( error ?: Error ) : void {
256
256
child ?. kill ( ) ;
257
- done ?.( error ) ;
257
+ done ?.( normalize ( error ) ) ;
258
258
}
259
259
260
260
/** Called after each expect callback to check if we're complete */
@@ -397,8 +397,7 @@ export function createRunner(...paths: string[]) {
397
397
? { ...process . env , ...withEnv , SENTRY_DSN : `http://public@localhost:${ mockServerPort } /1337` }
398
398
: { ...process . env , ...withEnv } ;
399
399
400
- // eslint-disable-next-line no-console
401
- if ( process . env . DEBUG ) console . log ( 'starting scenario' , testPath , flags , env . SENTRY_DSN ) ;
400
+ if ( process . env . DEBUG ) log ( 'starting scenario' , testPath , flags , env . SENTRY_DSN ) ;
402
401
403
402
child = spawn ( 'node' , [ ...flags , testPath ] , { env } ) ;
404
403
@@ -425,8 +424,7 @@ export function createRunner(...paths: string[]) {
425
424
426
425
// Pass error to done to end the test quickly
427
426
child . on ( 'error' , e => {
428
- // eslint-disable-next-line no-console
429
- if ( process . env . DEBUG ) console . log ( 'scenario error' , e ) ;
427
+ if ( process . env . DEBUG ) log ( 'scenario error' , e ) ;
430
428
complete ( e ) ;
431
429
} ) ;
432
430
@@ -465,8 +463,7 @@ export function createRunner(...paths: string[]) {
465
463
logs . push ( line . trim ( ) ) ;
466
464
467
465
buffer = Buffer . from ( buffer . subarray ( splitIndex + 1 ) ) ;
468
- // eslint-disable-next-line no-console
469
- if ( process . env . DEBUG ) console . log ( 'line' , line ) ;
466
+ if ( process . env . DEBUG ) log ( 'line' , line ) ;
470
467
tryParseEnvelopeFromStdoutLine ( line ) ;
471
468
}
472
469
} ) ;
@@ -484,34 +481,40 @@ export function createRunner(...paths: string[]) {
484
481
method : 'get' | 'post' ,
485
482
path : string ,
486
483
headers : Record < string , string > = { } ,
487
- data ?: any , // axios accept any as data
484
+ data ?: unknown ,
488
485
) : Promise < T | undefined > {
489
486
try {
490
487
await waitFor ( ( ) => scenarioServerPort !== undefined ) ;
491
488
} catch ( e ) {
492
489
complete ( e as Error ) ;
493
- return undefined ;
490
+ return ;
494
491
}
495
492
496
493
const url = `http://localhost:${ scenarioServerPort } ${ path } ` ;
497
- if ( expectError ) {
498
- try {
499
- if ( method === 'get' ) {
500
- await axios . get ( url , { headers } ) ;
501
- } else {
502
- await axios . post ( url , data , { headers } ) ;
503
- }
504
- } catch ( e ) {
494
+
495
+ try {
496
+ if ( method === 'post' ) {
497
+ const res = await axios . post ( url , data , { headers } ) ;
498
+ return res . data ;
499
+ } else {
500
+ const res = await axios . get ( url , { headers } ) ;
501
+ return res . data ;
502
+ }
503
+ } catch ( e ) {
504
+ if ( expectError ) {
505
505
return ;
506
506
}
507
+
508
+ complete ( e as Error ) ;
507
509
return ;
508
- } else if ( method === 'get' ) {
509
- return ( await axios . get ( url , { headers } ) ) . data ;
510
- } else {
511
- return ( await axios . post ( url , data , { headers } ) ) . data ;
512
510
}
513
511
} ,
514
512
} ;
515
513
} ,
516
514
} ;
517
515
}
516
+
517
+ function log ( ...args : unknown [ ] ) : void {
518
+ // eslint-disable-next-line no-console
519
+ console . log ( ...args . map ( arg => normalize ( arg ) ) ) ;
520
+ }
0 commit comments