Skip to content

Commit 0e8aaf3

Browse files
committed
test fork rejection behavior
1 parent 02fc6a1 commit 0e8aaf3

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

test/fixture/immediate-3-exit.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
process.exit(3);

test/fork.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ test('exit after tests are finished', function (t) {
6060
});
6161
});
6262

63+
test('rejects promise if the process exits with a non-zero code', function (t) {
64+
return fork(fixture('immediate-3-exit.js'))
65+
.catch(function (err) {
66+
t.is(err.name, 'AvaError');
67+
t.is(err.message, 'test/fixture/immediate-3-exit.js exited with a non-zero exit code: 3');
68+
});
69+
});
70+
71+
test('rejects promise if the process exits without results', function (t) {
72+
return fork(fixture('immediate-0-exit.js'))
73+
.catch(function (err) {
74+
t.is(err.name, 'AvaError');
75+
t.is(err.message, 'Test results were not received from test/fixture/immediate-0-exit.js');
76+
});
77+
});
78+
6379
test('fake timers do not break duration', function (t) {
6480
fork(fixture('fake-timers.js'))
6581
.run({})

0 commit comments

Comments
 (0)