@@ -137,6 +137,23 @@ describe('watch mode', { concurrency: false, timeout: 60_000 }, () => {
137
137
} ) ;
138
138
} ) ;
139
139
140
+ it ( 'should watch changes to a file with watch-path' , {
141
+ skip : ! supportsRecursive ,
142
+ } , async ( ) => {
143
+ const file = createTmpFile ( ) ;
144
+ const watchedFile = fixtures . path ( 'watch-mode/subdir/file.js' ) ;
145
+ const { stderr, stdout } = await spawnWithRestarts ( {
146
+ file,
147
+ watchedFile,
148
+ args : [ '--watch-path' , fixtures . path ( './watch-mode/subdir' ) , file ] ,
149
+ } ) ;
150
+ assert . strictEqual ( stderr , '' ) ;
151
+ assertRestartedCorrectly ( {
152
+ stdout,
153
+ messages : { inner : 'running' , completed : `Completed running ${ inspect ( file ) } ` , restarted : `Restarting ${ inspect ( file ) } ` } ,
154
+ } ) ;
155
+ } ) ;
156
+
140
157
it ( 'should watch when running an non-existing file - when specified under --watch-path' , {
141
158
skip : ! supportsRecursive
142
159
} , async ( ) => {
@@ -148,7 +165,28 @@ describe('watch mode', { concurrency: false, timeout: 60_000 }, () => {
148
165
args : [ '--watch-path' , fixtures . path ( './watch-mode/subdir/' ) , file ] ,
149
166
} ) ;
150
167
151
- assert . strictEqual ( stderr , '' ) ;
168
+ assert . match ( stderr , / E r r o r : C a n n o t f i n d m o d u l e / ) ;
169
+ assert ( stderr . match ( / E r r o r : C a n n o t f i n d m o d u l e / g) . length >= 2 ) ;
170
+
171
+ assertRestartedCorrectly ( {
172
+ stdout,
173
+ messages : { completed : `Failed running ${ inspect ( file ) } ` , restarted : `Restarting ${ inspect ( file ) } ` } ,
174
+ } ) ;
175
+ } ) ;
176
+
177
+ it ( 'should watch when running an non-existing file - when specified under --watch-path with equals' , {
178
+ skip : ! supportsRecursive
179
+ } , async ( ) => {
180
+ const file = fixtures . path ( 'watch-mode/subdir/non-existing.js' ) ;
181
+ const watchedFile = fixtures . path ( 'watch-mode/subdir/file.js' ) ;
182
+ const { stderr, stdout } = await spawnWithRestarts ( {
183
+ file,
184
+ watchedFile,
185
+ args : [ `--watch-path=${ fixtures . path ( './watch-mode/subdir/' ) } ` , file ] ,
186
+ } ) ;
187
+
188
+ assert . match ( stderr , / E r r o r : C a n n o t f i n d m o d u l e / ) ;
189
+ assert ( stderr . match ( / E r r o r : C a n n o t f i n d m o d u l e / g) . length >= 2 ) ;
152
190
assertRestartedCorrectly ( {
153
191
stdout,
154
192
messages : { completed : `Failed running ${ inspect ( file ) } ` , restarted : `Restarting ${ inspect ( file ) } ` } ,
0 commit comments