Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tests for the timeout option #332

Merged
merged 1 commit into from
Jun 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Down Expand Up @@ -112,12 +112,17 @@ test('timeout must be an integer', async t => {
}, INVALID_TIMEOUT_REGEXP);
});

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