Skip to content

Commit

Permalink
Improve tests for the reject option (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored and sindresorhus committed May 11, 2019
1 parent 3973fd4 commit e55dc8b
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,14 @@ test('execa.sync() throws error if written to stderr', t => {
}, process.platform === 'win32' ? /failed with exit code 1/ : /spawnSync foo ENOENT/);
});

test('skip throwing when using reject option in execa.sync()', t => {
const error = execa.sync('noop-err', ['foo'], {reject: false});
t.is(error.stderr, 'foo');
test('skip throwing when using reject option', async t => {
const error = await execa('fail', {reject: false});
t.is(error.exitCode, 2);
});

test('skip throwing when using reject option in sync mode', t => {
const error = execa.sync('fail', {reject: false});
t.is(error.exitCode, 2);
});

test('stripEof option (legacy)', async t => {
Expand Down Expand Up @@ -231,12 +236,6 @@ test('do not buffer stderr when `buffer` set to `false`', async t => {
t.is(stderr, '.........\n');
});

test('skip throwing when using reject option', async t => {
const error = await execa('exit', ['2'], {reject: false});
t.is(typeof error.stdout, 'string');
t.is(typeof error.stderr, 'string');
});

test('allow unknown exit code', async t => {
const {exitCode, exitCodeName} = await t.throwsAsync(execa('exit', ['255']), {message: /exit code 255 \(Unknown system error -255\)/});
t.is(exitCode, 255);
Expand Down

0 comments on commit e55dc8b

Please sign in to comment.