1- import { spawn } from 'node:child_process' ;
21import path from 'node:path' ;
32import { stripVTControlCharacters as stripAnsi } from 'node:util' ;
43import { describe , expect , onTestFinished , test } from '@rstest/core' ;
54import fse from 'fs-extra' ;
65import {
6+ expectBuildEnd ,
77 expectFile ,
88 expectFileWithContent ,
9- rslibBinPath ,
109 runCli ,
1110} from 'test-helper' ;
1211
@@ -90,6 +89,10 @@ export default defineConfig({
9089 index: ['./test-temp-src/**'],
9190 },
9291 },
92+ performance: {
93+ buildCache: false,
94+ printFileSize: false,
95+ },
9396});
9497` ,
9598 ) ;
@@ -101,20 +104,17 @@ export default defineConfig({
101104 const distFooFile = path . join ( __dirname , 'dist/esm/foo.js' ) ;
102105 const distFoo2File = path . join ( __dirname , 'dist/esm/foo2.js' ) ;
103106
104- const child = spawn (
105- 'node' ,
106- [ rslibBinPath , 'build' , '--watch' , '-c' , tempConfigFile ] ,
107- {
108- cwd : __dirname ,
109- stdio : 'pipe' ,
110- shell : true ,
111- } ,
112- ) ;
107+ const { child } = runCli ( `build --watch -c ${ tempConfigFile } ` , {
108+ cwd : __dirname ,
109+ } ) ;
113110 await expectFileWithContent ( distIndexFile , 'index' ) ;
114111
115112 fse . outputFileSync ( srcFooFile , `export const foo = 'foo';` ) ;
116- fse . outputFileSync ( srcFoo2File , `export const foo2 = 'foo2';` ) ;
113+ await expectBuildEnd ( child ) ;
117114 await expectFileWithContent ( distFooFile , `'foo'` ) ;
115+
116+ fse . outputFileSync ( srcFoo2File , `export const foo2 = 'foo2';` ) ;
117+ await expectBuildEnd ( child ) ;
118118 await expectFileWithContent ( distFoo2File , 'foo2' ) ;
119119
120120 const content1 = await fse . readFile ( distFooFile , 'utf-8' ) ;
@@ -136,6 +136,7 @@ export default defineConfig({
136136
137137 // change
138138 fse . outputFileSync ( srcFooFile , `export const foo1 = 'foo1';` ) ;
139+ await expectBuildEnd ( child ) ;
139140 await expectFileWithContent ( distFooFile , 'foo1' ) ;
140141 const content3 = await fse . readFile ( distFooFile , 'utf-8' ) ;
141142 expect ( content3 ! ) . toMatchInlineSnapshot ( `
0 commit comments