From f83a3d21fe2721c7c3e142d6a93caa8d0511fed5 Mon Sep 17 00:00:00 2001 From: Gabe Gorelick Date: Wed, 5 Jun 2019 16:39:09 -0500 Subject: [PATCH] Fix No Files error when file is passed via --files Fixes #3941 --- lib/cli/run-helpers.js | 23 ++++++++++++----------- test/integration/options/file.spec.js | 12 ++++++++++++ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/lib/cli/run-helpers.js b/lib/cli/run-helpers.js index a3848598f9..d995a7c75e 100644 --- a/lib/cli/run-helpers.js +++ b/lib/cli/run-helpers.js @@ -139,6 +139,18 @@ exports.handleFiles = ({ files = files.concat(newFiles); }); + const fileArgs = file.map(filepath => path.resolve(filepath)); + files = files.map(filepath => path.resolve(filepath)); + + // ensure we don't sort the stuff from fileArgs; order is important! + if (sort) { + files.sort(); + } + + // add files given through --file to be ran first + files = fileArgs.concat(files); + debug('files (in order): ', files); + if (!files.length) { // give full message details when only 1 file is missing const noneFoundMsg = @@ -154,17 +166,6 @@ exports.handleFiles = ({ }); } - const fileArgs = file.map(filepath => path.resolve(filepath)); - files = files.map(filepath => path.resolve(filepath)); - - // ensure we don't sort the stuff from fileArgs; order is important! - if (sort) { - files.sort(); - } - - // add files given through --file to be ran first - files = fileArgs.concat(files); - debug('files (in order): ', files); return files; }; diff --git a/test/integration/options/file.spec.js b/test/integration/options/file.spec.js index f96b58668d..cbe361d8aa 100644 --- a/test/integration/options/file.spec.js +++ b/test/integration/options/file.spec.js @@ -52,4 +52,16 @@ describe('--file', function() { done(); }); }); + + it('should support having no other test files', function(done) { + args = ['--file', resolvePath(fixtures.alpha)]; + + runMochaJSON('filethatdoesnotexist.js', args, function(err, res) { + if (err) { + return done(err); + } + expect(res, 'to have passed').and('to have passed test count', 1); + done(); + }); + }); });