File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -8,22 +8,24 @@ const args = ['--interactive'];
8
8
const opts = { cwd : fixtures . path ( 'es-modules' ) } ;
9
9
const child = cp . spawn ( process . execPath , args , opts ) ;
10
10
11
- let output = '' ;
11
+ const outputs = [ ] ;
12
12
child . stdout . setEncoding ( 'utf8' ) ;
13
13
child . stdout . on ( 'data' , ( data ) => {
14
- output += data ;
14
+ outputs . push ( data ) ;
15
+ if ( outputs . length === 3 ) {
16
+ // All the expected outputs have been received
17
+ // so we can close the child process's stdin
18
+ child . stdin . end ( ) ;
19
+ }
15
20
} ) ;
16
21
17
22
child . on ( 'exit' , common . mustCall ( ( ) => {
18
- const results = output . replace ( / ^ > / mg , '' ) . split ( '\n' ) . slice ( 2 ) ;
19
- assert . deepStrictEqual (
23
+ const results = outputs [ 2 ] . split ( '\n' ) [ 0 ] ;
24
+ assert . strictEqual (
20
25
results ,
21
- [ '[Module: null prototype] { message: \'A message\' }' , '' ]
26
+ '[Module: null prototype] { message: \'A message\' }'
22
27
) ;
23
28
} ) ) ;
24
29
25
30
child . stdin . write ( 'await import(\'./message.mjs\');\n' ) ;
26
31
child . stdin . write ( '.exit' ) ;
27
- setTimeout ( ( ) => {
28
- child . stdin . end ( ) ;
29
- } , common . platformTimeout ( 300 ) ) ;
You can’t perform that action at this time.
0 commit comments