Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

fixes failure output in mocha init w/o target

Christopher Hiller7c8896c70faf
diff --git a/lib/cli/cli.js b/lib/cli/cli.js
index 2e004ba4..ffbe5dad 100755
--- a/lib/cli/cli.js
+++ b/lib/cli/cli.js
@@ -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')
diff --git a/test/integration/init.spec.js b/test/integration/init.spec.js
index 176b852c..3961b278 100644
--- a/test/integration/init.spec.js
+++ b/test/integration/init.spec.js
@@ -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) {