Skip to content

Commit

Permalink
Improve tests for the timeout option
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jun 27, 2019
1 parent b336fbf commit 2cf1a28
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/kill.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ test('execa() returns a promise with kill()', t => {
});

test('timeout kills the process if it times out', async t => {
const {killed, timedOut} = await t.throwsAsync(execa('forever', {timeout: 1, message: TIMEOUT_REGEXP}));
const {killed, timedOut} = await t.throwsAsync(execa('forever', {timeout: 1}), TIMEOUT_REGEXP);
t.false(killed);
t.true(timedOut);
});
Expand All @@ -98,12 +98,17 @@ test('timeout does not kill the process if it does not time out', async t => {
t.false(timedOut);
});

test('timedOut is false if no timeout was set', async t => {
test('timedOut is false if timeout is undefined', async t => {
const {timedOut} = await execa('noop');
t.false(timedOut);
});

test('timedOut will be false if no timeout was set and zero exit code in sync mode', t => {
test('timedOut is false if timeout is 0', async t => {
const {timedOut} = await execa('noop', {timeout: 0});
t.false(timedOut);
});

test('timedOut is false if timeout is undefined and exit code is 0 in sync mode', t => {
const {timedOut} = execa.sync('noop');
t.false(timedOut);
});
Expand Down

0 comments on commit 2cf1a28

Please sign in to comment.