@@ -391,7 +391,7 @@ const normalizeReporters = ({
391391 } ) ;
392392} ;
393393
394- const buildTestPathPattern = ( argv : Config . Argv ) : string => {
394+ const buildTestPathPatterns = ( argv : Config . Argv ) : TestPathPatterns => {
395395 const patterns = [ ] ;
396396
397397 if ( argv . _ ) {
@@ -402,21 +402,20 @@ const buildTestPathPattern = (argv: Config.Argv): string => {
402402 }
403403
404404 const testPathPatterns = new TestPathPatterns ( patterns ) ;
405- if ( testPathPatterns . isValid ( ) ) {
406- return testPathPatterns . regexString ;
407- } else {
408- showTestPathPatternError ( testPathPatterns . regexString ) ;
409- return '' ;
405+ if ( ! testPathPatterns . isValid ( ) ) {
406+ showTestPathPatternsError ( testPathPatterns ) ;
407+ return new TestPathPatterns ( [ ] ) ;
410408 }
409+ return testPathPatterns ;
411410} ;
412411
413- const showTestPathPatternError = ( testPathPattern : string ) => {
412+ const showTestPathPatternsError = ( testPathPatterns : TestPathPatterns ) => {
414413 clearLine ( process . stdout ) ;
415414
416415 // eslint-disable-next-line no-console
417416 console . log (
418417 chalk . red (
419- ` Invalid testPattern ${ testPathPattern } supplied. ` +
418+ ` Invalid testPattern ${ testPathPatterns . toPretty ( ) } supplied. ` +
420419 'Running all tests instead.' ,
421420 ) ,
422421 ) ;
@@ -998,7 +997,8 @@ export default async function normalize(
998997 }
999998
1000999 newOptions . nonFlagArgs = argv . _ ?. map ( arg => `${ arg } ` ) ;
1001- newOptions . testPathPattern = buildTestPathPattern ( argv ) ;
1000+ const testPathPatterns = buildTestPathPatterns ( argv ) ;
1001+ newOptions . testPathPattern = testPathPatterns . regexString ;
10021002 newOptions . json = ! ! argv . json ;
10031003
10041004 newOptions . testFailureExitCode = parseInt (
@@ -1017,7 +1017,7 @@ export default async function normalize(
10171017 if ( argv . all ) {
10181018 newOptions . onlyChanged = false ;
10191019 newOptions . onlyFailures = false ;
1020- } else if ( newOptions . testPathPattern ) {
1020+ } else if ( testPathPatterns . isSet ( ) ) {
10211021 // When passing a test path pattern we don't want to only monitor changed
10221022 // files unless `--watch` is also passed.
10231023 newOptions . onlyChanged = newOptions . watch ;
0 commit comments