@@ -2,7 +2,7 @@ import { describe, it, expect, afterAll } from 'vitest';
22import { copyFileSync , mkdtempSync , rmSync } from 'fs' ;
33import { join } from 'path' ;
44import { tmpdir } from 'os' ;
5- import { spawnSync } from 'child_process' ;
5+ import { spawn } from 'child_process' ;
66
77const TEMPLATE_PACKAGE_JSON = join ( __dirname , 'package.json' ) ;
88
@@ -18,15 +18,17 @@ describe('docusaurus template bundle dependencies', () => {
1818 rmSync ( tmpDir , { recursive : true , force : true } ) ;
1919 } ) ;
2020
21- it ( 'should resolve without peer dependency conflicts (long running test)' , ( ) => {
21+ it ( 'should resolve without peer dependency conflicts (long running test)' , async ( ) => {
2222 copyFileSync ( TEMPLATE_PACKAGE_JSON , join ( tmpDir , 'package.json' ) ) ;
2323
24- const result = spawnSync (
25- 'npm' ,
26- [ 'install' , '--package-lock-only' , '--prefix' , tmpDir ] ,
27- { encoding : 'utf-8' }
28- ) ;
24+ const exitCode = await new Promise < number > ( ( resolve , reject ) => {
25+ const stderr : string [ ] = [ ] ;
26+ const proc = spawn ( 'npm' , [ 'install' , '--package-lock-only' , '--prefix' , tmpDir ] ) ;
27+ proc . stderr ?. on ( 'data' , ( chunk : Buffer ) => stderr . push ( chunk . toString ( ) ) ) ;
28+ proc . on ( 'close' , ( code ) => resolve ( code ?? 1 ) ) ;
29+ proc . on ( 'error' , reject ) ;
30+ } ) ;
2931
30- expect ( result . status , result . stderr ) . toBe ( 0 ) ;
31- } , 180_000 ) ;
32+ expect ( exitCode ) . toBe ( 0 ) ;
33+ } , 120_000 ) ;
3234} ) ;
0 commit comments