Skip to content

Commit

Permalink
give message if only 1 file missing
Browse files Browse the repository at this point in the history
  • Loading branch information
craigtaub committed Jan 4, 2019
1 parent b6fd9bc commit 7be247e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/cli/run-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,12 @@ exports.handleFiles = ({
});

if (!files.length) {
console.error(ansi.red('Error: No test files found'));
if (missingMessages.length === 1) {
// give message details when only 1 missing file
console.error(ansi.red(`Error: ${missingMessages[0]}`));
} else {
console.error(ansi.red('Error: No test files found'));
}
process.exit(1);
} else {
// print messages as an warning
Expand Down
34 changes: 33 additions & 1 deletion test/integration/glob.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ describe('globbing', function() {
it('should not find a non-matching pattern', function(done) {
testGlob.shouldFail(
'./*-none.js',
function(results) {
expect(
results.stderr,
'to contain',
'Error: Cannot find any files matching pattern'
);
},
done
);
});

it('should handle multiple non-matching patterns', function(done) {
testGlob.shouldFail(
'./*-none.js ./*-none-twice.js',
function(results) {
expect(results.stderr, 'to contain', 'Error: No test files found');
},
Expand Down Expand Up @@ -69,6 +83,20 @@ describe('globbing', function() {
it('should not find a non-matching pattern', function(done) {
testGlob.shouldFail(
'"./*-none.js"',
function(results) {
expect(
results.stderr,
'to contain',
'Error: Cannot find any files matching pattern'
);
},
done
);
});

it('should handle multiple non-matching patterns', function(done) {
testGlob.shouldFail(
'"./*-none.js" "./*-none-twice.js"',
function(results) {
expect(results.stderr, 'to contain', 'Error: No test files found');
},
Expand Down Expand Up @@ -114,7 +142,11 @@ describe('globbing', function() {
testGlob.shouldFail(
'"./**/*-none.js"',
function(results) {
expect(results.stderr, 'to contain', 'Error: No test files found');
expect(
results.stderr,
'to contain',
'Error: Cannot find any files matching pattern'
);
},
done
);
Expand Down

0 comments on commit 7be247e

Please sign in to comment.