@@ -190,10 +190,34 @@ function collect(browserNames) {
190
190
delete global [ key ] ;
191
191
}
192
192
193
+ return testRunner ;
194
+ }
195
+
196
+ module . exports = collect ;
197
+
198
+ if ( require . main === module ) {
199
+ console . log ( 'Testing on Node' , process . version ) ;
200
+ const browserNames = [ 'chromium' , 'firefox' , 'webkit' ] . filter ( name => {
201
+ return process . env . BROWSER === name || process . env . BROWSER === 'all' ;
202
+ } ) ;
203
+ const testRunner = collect ( browserNames ) ;
204
+
193
205
const filterArgIndex = process . argv . indexOf ( '--filter' ) ;
194
206
if ( filterArgIndex !== - 1 ) {
195
207
const filter = process . argv [ filterArgIndex + 1 ] ;
196
- testRunner . focusMatchingTests ( new RegExp ( filter , 'i' ) ) ;
208
+ if ( ! testRunner . focusMatchingNameTests ( new RegExp ( filter , 'i' ) ) . length ) {
209
+ console . log ( 'ERROR: no tests matched given `--filter` regex.' ) ;
210
+ process . exit ( 1 ) ;
211
+ }
212
+ }
213
+
214
+ const fileArgIndex = process . argv . indexOf ( '--file' ) ;
215
+ if ( fileArgIndex !== - 1 ) {
216
+ const filter = process . argv [ fileArgIndex + 1 ] ;
217
+ if ( ! testRunner . focusMatchingFilePath ( new RegExp ( filter , 'i' ) ) . length ) {
218
+ console . log ( 'ERROR: no files matched given `--file` regex.' ) ;
219
+ process . exit ( 1 ) ;
220
+ }
197
221
}
198
222
199
223
const repeatArgIndex = process . argv . indexOf ( '--repeat' ) ;
@@ -203,16 +227,5 @@ function collect(browserNames) {
203
227
testRunner . repeatAll ( repeat ) ;
204
228
}
205
229
206
- return testRunner ;
207
- }
208
-
209
- module . exports = collect ;
210
-
211
- if ( require . main === module ) {
212
- console . log ( 'Testing on Node' , process . version ) ;
213
- const browserNames = [ 'chromium' , 'firefox' , 'webkit' ] . filter ( name => {
214
- return process . env . BROWSER === name || process . env . BROWSER === 'all' ;
215
- } ) ;
216
- const testRunner = collect ( browserNames ) ;
217
230
testRunner . run ( ) . then ( ( ) => { delete global . expect ; } ) ;
218
231
}
0 commit comments