Skip to content

Commit 378cc83

Browse files
committed
test(cli): harden harness against side effects
1 parent 59fd6e5 commit 378cc83

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

@commitlint/cli/cli.test.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const here = path.join.bind(null, __dirname);
77

88
const SIMPLE = here('fixtures/simple');
99
const EXTENDS_ROOT = here('fixtures/extends-root');
10+
const EMPTY = here('fixtures/empty');
1011

1112
const cli = (input = '', args = [], opts = {}) => {
1213
const c = execa(here('cli.js'), args, {
@@ -22,24 +23,24 @@ test('should throw when called without [input]', t => {
2223
});
2324

2425
test('should reprint input from stdin', async t => {
25-
const actual = await cli('foo: bar');
26+
const actual = await cli('foo: bar', [], {cwd: EMPTY});
2627
t.true(actual.stdout.includes('foo: bar'));
2728
});
2829

2930
test('should produce no success output with --quiet flag', async t => {
30-
const actual = await cli('foo: bar', ['--quiet']);
31+
const actual = await cli('foo: bar', ['--quiet'], {cwd: EMPTY});
3132
t.is(actual.stdout, '');
3233
t.is(actual.stderr, '');
3334
});
3435

3536
test('should produce no success output with -q flag', async t => {
36-
const actual = await cli('foo: bar', ['-q']);
37+
const actual = await cli('foo: bar', ['-q'], {cwd: EMPTY});
3738
t.is(actual.stdout, '');
3839
t.is(actual.stderr, '');
3940
});
4041

4142
test('should succeed for input from stdin without rules', async t => {
42-
const actual = await cli('foo: bar');
43+
const actual = await cli('foo: bar', [], {cwd: EMPTY});
4344
t.is(actual.code, 0);
4445
});
4546

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)