11import { writeFile } from 'node:fs/promises' ;
22import path from 'node:path' ;
3- import { waitForFile } from '@rstackjs/test-utils' ;
3+ import { waitFor , waitForFile } from '@rstackjs/test-utils' ;
44import { test } from '#test-helpers' ;
55
66test ( 'should restart lib watch build when Rstack config changes' , async ( {
@@ -44,6 +44,8 @@ define.lib({
4444 execCliAsync ( 'lib --watch --config test-temp-rstack.config.ts' ) ;
4545 await logHelper . expectLog ( 'build completed, watching for changes...' ) ;
4646 await waitForFile ( path . join ( dist1 , 'index.js' ) ) ;
47+ // The build log precedes the restart watcher's initial filesystem scan.
48+ await waitFor ( 100 ) ;
4749 logHelper . clearLogs ( ) ;
4850
4951 await writeConfig ( 'dist-2' ) ;
@@ -53,6 +55,7 @@ define.lib({
5355 ) ;
5456 await logHelper . expectLog ( 'build completed, watching for changes...' ) ;
5557 await waitForFile ( path . join ( dist2 , 'index.js' ) ) ;
58+ await waitFor ( 100 ) ;
5659 logHelper . clearLogs ( ) ;
5760
5861 await writeFile ( userWatchFile , 'changed\n' ) ;
@@ -93,6 +96,7 @@ define.lib({
9396 execCliAsync ( 'lib --watch --config test-temp-import.config.ts' ) ;
9497 await logHelper . expectLog ( 'build completed, watching for changes...' ) ;
9598 await waitForFile ( path . join ( dist1 , 'index.js' ) ) ;
99+ await waitFor ( 100 ) ;
96100 logHelper . clearLogs ( ) ;
97101
98102 await writeFile ( importedFile , "export const distPath = 'dist-import-2';\n" ) ;
@@ -138,6 +142,7 @@ define.extends([sharedConfig]);
138142 execCliAsync ( 'lib --watch --config test-temp-shared.config.ts' ) ;
139143 await logHelper . expectLog ( 'build completed, watching for changes...' ) ;
140144 await waitForFile ( path . join ( dist1 , 'index.js' ) ) ;
145+ await waitFor ( 100 ) ;
141146 logHelper . clearLogs ( ) ;
142147
143148 await writeFile (
0 commit comments