Skip to content

Commit 5d4dd98

Browse files
gabegorelickjuergba
authored andcommitted
Fix No Files error when file is passed via --files (#3942)
Fixes #3941
1 parent 15b96af commit 5d4dd98

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

lib/cli/collect-files.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ module.exports = ({ignore, extension, file, recursive, sort, spec} = {}) => {
5454
files = files.concat(newFiles);
5555
});
5656

57+
const fileArgs = file.map(filepath => path.resolve(filepath));
58+
files = files.map(filepath => path.resolve(filepath));
59+
60+
// ensure we don't sort the stuff from fileArgs; order is important!
61+
if (sort) {
62+
files.sort();
63+
}
64+
65+
// add files given through --file to be ran first
66+
files = fileArgs.concat(files);
67+
debug('files (in order): ', files);
68+
5769
if (!files.length) {
5870
// give full message details when only 1 file is missing
5971
const noneFoundMsg =
@@ -69,16 +81,5 @@ module.exports = ({ignore, extension, file, recursive, sort, spec} = {}) => {
6981
});
7082
}
7183

72-
const fileArgs = file.map(filepath => path.resolve(filepath));
73-
files = files.map(filepath => path.resolve(filepath));
74-
75-
// ensure we don't sort the stuff from fileArgs; order is important!
76-
if (sort) {
77-
files.sort();
78-
}
79-
80-
// add files given through --file to be ran first
81-
files = fileArgs.concat(files);
82-
debug('files (in order): ', files);
8384
return files;
8485
};

test/integration/options/file.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,16 @@ describe('--file', function() {
5252
done();
5353
});
5454
});
55+
56+
it('should support having no other test files', function(done) {
57+
args = ['--file', resolvePath(fixtures.alpha)];
58+
59+
runMochaJSON('filethatdoesnotexist.js', args, function(err, res) {
60+
if (err) {
61+
return done(err);
62+
}
63+
expect(res, 'to have passed').and('to have passed test count', 1);
64+
done();
65+
});
66+
});
5567
});

0 commit comments

Comments
 (0)