Skip to content

Commit

Permalink
fixes failure output in mocha init w/o target
Browse files Browse the repository at this point in the history
`yargs.exit()` is not always present, apparently. it will throw in this case--we don't need to be calling it anyway.
  • Loading branch information
boneskull committed Jul 7, 2020
1 parent 7000336 commit 7c8896c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/cli/cli.js
Expand Up @@ -52,7 +52,7 @@ exports.main = (argv = process.argv.slice(2)) => {
debug('caught error sometime before command handler: %O', err);
yargs.showHelp();
console.error(`\n${symbols.error} ${ansi.red('ERROR:')} ${msg}`);
yargs.exit(1);
process.exitCode = 1;
})
.help('help', 'Show usage information & exit')
.alias('help', 'h')
Expand Down
46 changes: 33 additions & 13 deletions test/integration/init.spec.js
Expand Up @@ -23,19 +23,39 @@ describe('init command', function() {
} catch (ignored) {}
});

it('should break if no path supplied', function(done) {
invokeMocha(
['init'],
function(err, result) {
if (err) {
return done(err);
}
expect(result, 'to have failed');
expect(result.output, 'to match', /not enough non-option arguments/i);
done();
},
{stdio: 'pipe'}
);
describe('when no path is supplied', function() {
it('should fail', function(done) {
invokeMocha(
['init'],
function(err, result) {
if (err) {
return done(err);
}
expect(
result,
'to have failed with output',
/not enough non-option arguments/i
);
done();
},
{stdio: 'pipe'}
);
});
it('should not throw', function(done) {
invokeMocha(
['init'],
function(err, result) {
if (err) {
return done(err);
}
expect(result, 'to have failed').and('not to satisfy', {
output: /throw/i
});
done();
},
{stdio: 'pipe'}
);
});
});

it('should create some files in the dest dir', function(done) {
Expand Down

0 comments on commit 7c8896c

Please sign in to comment.