Skip to content

Commit 9997da6

Browse files
authored
fix: "codeceptjs" command outputs help message twice (#4278)
* fix "codeceptjs" command outputs help message twice * add tests
1 parent 4de7b19 commit 9997da6

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

bin/codecept.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,5 +272,6 @@ program.on('command:*', (cmd) => {
272272

273273
if (process.argv.length <= 2) {
274274
program.outputHelp();
275+
} else {
276+
program.parse(process.argv);
275277
}
276-
program.parse(process.argv);

test/runner/help_test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const assert = require('assert');
2+
const path = require('path');
3+
const exec = require('child_process').exec;
4+
5+
const runner = path.join(__dirname, '/../../bin/codecept.js');
6+
7+
describe('help option', () => {
8+
it('should print help message with --help option', (done) => {
9+
exec(`${runner} --help`, (err, stdout) => {
10+
stdout.should.include('Usage:');
11+
stdout.should.include('Options:');
12+
stdout.should.include('Commands:');
13+
assert(!err);
14+
done();
15+
});
16+
});
17+
18+
it('should print help message with -h option', (done) => {
19+
exec(`${runner} -h`, (err, stdout) => {
20+
stdout.should.include('Usage:');
21+
stdout.should.include('Options:');
22+
stdout.should.include('Commands:');
23+
assert(!err);
24+
done();
25+
});
26+
});
27+
28+
it('should print help message with no option', (done) => {
29+
exec(`${runner}`, (err, stdout) => {
30+
stdout.should.include('Usage:');
31+
stdout.should.include('Options:');
32+
stdout.should.include('Commands:');
33+
assert(!err);
34+
done();
35+
});
36+
});
37+
});

0 commit comments

Comments
 (0)