@@ -8,9 +8,27 @@ const NODE_MAJOR_VERSION = parseInt(process.versions.node.split('.')[0], 10);
88
99function runTest ( ...paths ) {
1010 const file = join ( ...paths ) ;
11- const args = NODE_MAJOR_VERSION === 22 ? [ '--experimental-async-context-frame' , file ] : [ file ] ;
12- const result = spawnSync ( 'node' , args , { stdio : 'inherit' } ) ;
13- return result ;
11+ const args = NODE_MAJOR_VERSION === 22 ? [ '--experimental-async-context-frame' , file ] : [ file ] ;
12+ const result = spawnSync ( 'node' , args ) ;
13+ const stdoutLines = result . stdout ?. toString ( ) . split ( '\n' ) . filter ( line => line . trim ( ) !== '' ) ;
14+ const stderrLines = result . stderr ?. toString ( ) . split ( '\n' ) . filter ( line => line . trim ( ) !== '' ) ;
15+
16+ let trace ;
17+ for ( const line of stdoutLines ) {
18+ try {
19+ trace = JSON . parse ( line ) ;
20+ break ;
21+ } catch ( _ ) {
22+ //
23+ }
24+ }
25+
26+ console . log ( 'Test stdout:' , stdoutLines ) ;
27+ if ( stderrLines . length > 0 ) {
28+ console . log ( 'Test stderr:' , stderrLines ) ;
29+ }
30+
31+ return { status : result . status , stdoutLines, trace : trace } ;
1432}
1533
1634describe ( 'e2e Tests' , { timeout : 20000 } , ( ) => {
@@ -19,9 +37,7 @@ describe('e2e Tests', { timeout: 20000 }, () => {
1937
2038 expect ( result . status ) . toEqual ( 0 ) ;
2139
22- const trace = JSON . parse ( result . stdout . toString ( ) ) ;
23-
24- expect ( trace ) . toEqual ( expect . objectContaining ( {
40+ expect ( result . trace ) . toEqual ( expect . objectContaining ( {
2541 '0' : {
2642 frames : expect . arrayContaining ( [
2743 {
@@ -74,9 +90,7 @@ describe('e2e Tests', { timeout: 20000 }, () => {
7490
7591 expect ( result . status ) . toEqual ( 0 ) ;
7692
77- const trace = JSON . parse ( result . stdout . toString ( ) ) ;
78-
79- expect ( trace ) . toEqual ( expect . objectContaining ( {
93+ expect ( result . trace ) . toEqual ( expect . objectContaining ( {
8094 '0' : {
8195 frames : expect . arrayContaining ( [
8296 {
@@ -116,9 +130,7 @@ describe('e2e Tests', { timeout: 20000 }, () => {
116130
117131 expect ( result . status ) . toEqual ( 0 ) ;
118132
119- const trace = JSON . parse ( result . stdout . toString ( ) ) ;
120-
121- expect ( trace ) . toEqual ( expect . objectContaining ( {
133+ expect ( result . trace ) . toEqual ( expect . objectContaining ( {
122134 '0' : expect . objectContaining ( {
123135 frames : expect . arrayContaining ( [
124136 {
@@ -150,6 +162,6 @@ describe('e2e Tests', { timeout: 20000 }, () => {
150162
151163 expect ( result . status ) . toEqual ( 0 ) ;
152164
153- expect ( result . stdout . toString ( ) ) . toContain ( 'complete' ) ;
165+ expect ( result . stdoutLines ) . toContain ( 'complete' ) ;
154166 } ) ;
155167} ) ;
0 commit comments