diff --git a/bin/codecept.js b/bin/codecept.js index 9d8ddfc3c..e1386c3c6 100755 --- a/bin/codecept.js +++ b/bin/codecept.js @@ -236,5 +236,6 @@ program.on('command:*', (cmd) => { if (process.argv.length <= 2) { program.outputHelp(); +} else { + program.parse(process.argv); } -program.parse(process.argv); diff --git a/test/runner/help_test.js b/test/runner/help_test.js new file mode 100644 index 000000000..b9e0bf405 --- /dev/null +++ b/test/runner/help_test.js @@ -0,0 +1,37 @@ +const assert = require('assert'); +const path = require('path'); +const exec = require('child_process').exec; + +const runner = path.join(__dirname, '/../../bin/codecept.js'); + +describe('help option', () => { + it('should print help message with --help option', (done) => { + exec(`${runner} --help`, (err, stdout) => { + stdout.should.include('Usage:'); + stdout.should.include('Options:'); + stdout.should.include('Commands:'); + assert(!err); + done(); + }); + }); + + it('should print help message with -h option', (done) => { + exec(`${runner} -h`, (err, stdout) => { + stdout.should.include('Usage:'); + stdout.should.include('Options:'); + stdout.should.include('Commands:'); + assert(!err); + done(); + }); + }); + + it('should print help message with no option', (done) => { + exec(`${runner}`, (err, stdout) => { + stdout.should.include('Usage:'); + stdout.should.include('Options:'); + stdout.should.include('Commands:'); + assert(!err); + done(); + }); + }); +});