@@ -300,5 +300,64 @@ export default testSuite(async ({ describe }, { tsx }: NodeApis) => {
300
300
expect ( p . stderr ) . toBe ( '' ) ;
301
301
} , 10_000 ) ;
302
302
} ) ;
303
+
304
+ describe ( 'watch additional files' , ( { test } ) => {
305
+ test ( 'file path & glob' , async ( ) => {
306
+ const entryFile = 'index.js' ;
307
+ const fileA = 'file-a' ;
308
+ const fileB = 'directory/file-b' ;
309
+ await using fixture = await createFixture ( {
310
+ [ entryFile ] : `
311
+ import fs from 'fs/promises';
312
+ Promise.all([
313
+ fs.readFile('./${ fileA } ', 'utf8'),
314
+ fs.readFile('./${ fileB } ', 'utf8')
315
+ ]).then(console.log, console.error);
316
+ ` . trim ( ) ,
317
+ [ fileA ] : 'content-a' ,
318
+ [ fileB ] : 'content-b' ,
319
+ } ) ;
320
+
321
+ const tsxProcess = tsx (
322
+ [
323
+ 'watch' ,
324
+ '--clear-screen=false' ,
325
+ `--include=${ fileA } ` ,
326
+ '--include=directory/*' ,
327
+ entryFile ,
328
+ ] ,
329
+ fixture . path ,
330
+ ) ;
331
+
332
+ await processInteract (
333
+ tsxProcess . stdout ! ,
334
+ [
335
+ ( data ) => {
336
+ if ( data . includes ( "'content-a', 'content-b'" ) ) {
337
+ fixture . writeFile ( fileA , 'update-a' ) ;
338
+ return true ;
339
+ }
340
+ } ,
341
+ ( data ) => {
342
+ if ( data . includes ( "'update-a', 'content-b'" ) ) {
343
+ fixture . writeFile ( fileB , 'update-b' ) ;
344
+ return true ;
345
+ }
346
+ } ,
347
+ ( data ) => {
348
+ if ( data . includes ( "'update-a', 'update-b'" ) ) {
349
+ return true ;
350
+ }
351
+ } ,
352
+ ] ,
353
+ 9000 ,
354
+ ) ;
355
+
356
+ tsxProcess . kill ( ) ;
357
+
358
+ const tsxProcessResolved = await tsxProcess ;
359
+ expect ( tsxProcessResolved . stderr ) . toBe ( '' ) ;
360
+ } , 10_000 ) ;
361
+ } ) ;
303
362
} ) ;
304
363
} ) ;
0 commit comments