Skip to content

Commit f83a3d2

Browse files
committed
Fix No Files error when file is passed via --files
Fixes #3941
1 parent f3ed729 commit f83a3d2

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

lib/cli/run-helpers.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ exports.handleFiles = ({
139139
files = files.concat(newFiles);
140140
});
141141

142+
const fileArgs = file.map(filepath => path.resolve(filepath));
143+
files = files.map(filepath => path.resolve(filepath));
144+
145+
// ensure we don't sort the stuff from fileArgs; order is important!
146+
if (sort) {
147+
files.sort();
148+
}
149+
150+
// add files given through --file to be ran first
151+
files = fileArgs.concat(files);
152+
debug('files (in order): ', files);
153+
142154
if (!files.length) {
143155
// give full message details when only 1 file is missing
144156
const noneFoundMsg =
@@ -154,17 +166,6 @@ exports.handleFiles = ({
154166
});
155167
}
156168

157-
const fileArgs = file.map(filepath => path.resolve(filepath));
158-
files = files.map(filepath => path.resolve(filepath));
159-
160-
// ensure we don't sort the stuff from fileArgs; order is important!
161-
if (sort) {
162-
files.sort();
163-
}
164-
165-
// add files given through --file to be ran first
166-
files = fileArgs.concat(files);
167-
debug('files (in order): ', files);
168169
return files;
169170
};
170171

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)