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

fixes failure output in mocha init w/o target #4359

Merged
merged 1 commit into from Jul 7, 2020
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
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