@@ -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 */
@@ -379,6 +379,8 @@ export function createRunner(...paths: string[]) {
379
379
? runDockerCompose ( dockerOptions )
380
380
: Promise . resolve ( undefined ) ;
381
381
382
+ log ( 'before start' ) ;
383
+
382
384
const startup = Promise . all ( [ dockerStartup , serverStartup ] ) as Promise < [ DockerStartup , ServerStartup ] > ;
383
385
384
386
startup
@@ -397,8 +399,7 @@ export function createRunner(...paths: string[]) {
397
399
? { ...process . env , ...withEnv , SENTRY_DSN : `http://public@localhost:${ mockServerPort } /1337` }
398
400
: { ...process . env , ...withEnv } ;
399
401
400
- // eslint-disable-next-line no-console
401
- if ( process . env . DEBUG ) console . log ( 'starting scenario' , testPath , flags , env . SENTRY_DSN ) ;
402
+ if ( process . env . DEBUG ) log ( 'starting scenario' , testPath , flags , env . SENTRY_DSN ) ;
402
403
403
404
child = spawn ( 'node' , [ ...flags , testPath ] , { env } ) ;
404
405
@@ -425,8 +426,7 @@ export function createRunner(...paths: string[]) {
425
426
426
427
// Pass error to done to end the test quickly
427
428
child . on ( 'error' , e => {
428
- // eslint-disable-next-line no-console
429
- if ( process . env . DEBUG ) console . log ( 'scenario error' , e ) ;
429
+ if ( process . env . DEBUG ) log ( 'scenario error' , e ) ;
430
430
complete ( e ) ;
431
431
} ) ;
432
432
@@ -465,8 +465,7 @@ export function createRunner(...paths: string[]) {
465
465
logs . push ( line . trim ( ) ) ;
466
466
467
467
buffer = Buffer . from ( buffer . subarray ( splitIndex + 1 ) ) ;
468
- // eslint-disable-next-line no-console
469
- if ( process . env . DEBUG ) console . log ( 'line' , line ) ;
468
+ if ( process . env . DEBUG ) log ( 'line' , line ) ;
470
469
tryParseEnvelopeFromStdoutLine ( line ) ;
471
470
}
472
471
} ) ;
@@ -490,28 +489,34 @@ export function createRunner(...paths: string[]) {
490
489
await waitFor ( ( ) => scenarioServerPort !== undefined ) ;
491
490
} catch ( e ) {
492
491
complete ( e as Error ) ;
493
- return undefined ;
492
+ return ;
494
493
}
495
494
496
495
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 ) {
496
+
497
+ try {
498
+ if ( method === 'post' ) {
499
+ const res = await axios . post ( url , data , { headers } ) ;
500
+ return res . data ;
501
+ } else {
502
+ const res = await axios . get ( url , { headers } ) ;
503
+ return res . data ;
504
+ }
505
+ } catch ( e ) {
506
+ if ( expectError ) {
505
507
return ;
506
508
}
509
+
510
+ complete ( e as Error ) ;
507
511
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
512
}
513
513
} ,
514
514
} ;
515
515
} ,
516
516
} ;
517
517
}
518
+
519
+ function log ( ...args : unknown [ ] ) : void {
520
+ // eslint-disable-next-line no-console
521
+ console . log ( ...args . map ( arg => normalize ( arg ) ) ) ;
522
+ }
0 commit comments