diff --git a/lib/cli/run-helpers.js b/lib/cli/run-helpers.js index be9a3fcb18..76453c834b 100644 --- a/lib/cli/run-helpers.js +++ b/lib/cli/run-helpers.js @@ -138,13 +138,14 @@ exports.handleFiles = ({ spec = [] } = {}) => { let files = []; + let errors = []; spec.forEach(arg => { let newFiles; try { newFiles = utils.lookupFiles(arg, extension, recursive); } catch (err) { if (err.code === 'ERR_MOCHA_NO_FILES_MATCH_PATTERN') { - console.error(ansi.red(`${symbols.error} ${err.message}`)); + errors.push(err.message); return; } @@ -164,8 +165,16 @@ exports.handleFiles = ({ }); if (!files.length) { - // prints message about each individual missing file already + // print messages as an error + errors.forEach(message => { + console.error(ansi.red(`${symbols.error} ${message}`)); + }); process.exit(1); + } else { + // print messages as an warning + errors.forEach(message => { + console.warn(`Warning: ${message}`); + }); } const fileArgs = file.map(filepath => path.resolve(filepath)); diff --git a/test/integration/glob.spec.js b/test/integration/glob.spec.js index 0f70dd59b6..fe0d05532e 100644 --- a/test/integration/glob.spec.js +++ b/test/integration/glob.spec.js @@ -47,7 +47,7 @@ describe('globbing', function() { expect( results.stderr, 'to contain', - '✖ Cannot find any files matching pattern' + 'Warning: Cannot find any files matching pattern' ); }, done @@ -96,7 +96,7 @@ describe('globbing', function() { expect( results.stderr, 'to contain', - '✖ Cannot find any files matching pattern' + 'Warning: Cannot find any files matching pattern' ); }, done @@ -144,7 +144,7 @@ describe('globbing', function() { expect( results.stderr, 'to contain', - '✖ Cannot find any files matching pattern' + 'Warning: Cannot find any files matching pattern' ); }, done