Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix No Files error when file is passed via --files #3942

Merged
merged 1 commit into from Jun 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 12 additions & 11 deletions lib/cli/collect-files.js
Expand Up @@ -54,6 +54,18 @@ module.exports = ({ignore, extension, file, recursive, sort, spec} = {}) => {
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 =
Expand All @@ -69,16 +81,5 @@ module.exports = ({ignore, extension, file, recursive, sort, spec} = {}) => {
});
}

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;
};
12 changes: 12 additions & 0 deletions test/integration/options/file.spec.js
Expand Up @@ -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();
});
});
});