Skip to content

Commit a6fb0a7

Browse files
committed
Fix --fail-fast accidentally interrupting test files
The interrupt call wasn't properly guarded and ran whenever a test result was received, rather than when a test failed.
1 parent af2c2b6 commit a6fb0a7

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

api.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ class Api extends EventEmitter {
9898
runStatus.on('test', test => {
9999
if (test.error) {
100100
bailed = true;
101-
}
102101

103-
for (const fork of pendingForks) {
104-
fork.notifyOfPeerFailure();
102+
for (const fork of pendingForks) {
103+
fork.notifyOfPeerFailure();
104+
}
105105
}
106106
});
107107
}

test/api.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,37 @@ test('fail-fast mode - timeout & serial', t => {
385385
});
386386
});
387387

388+
test('fail-fast mode - no errors', t => {
389+
const api = apiCreator({
390+
failFast: true
391+
});
392+
393+
const tests = [];
394+
const errors = [];
395+
396+
api.on('test-run', runStatus => {
397+
runStatus.on('test', test => {
398+
tests.push({
399+
ok: !test.error,
400+
title: test.title
401+
});
402+
});
403+
runStatus.on('error', err => {
404+
errors.push(err);
405+
});
406+
});
407+
408+
return api.run([
409+
path.join(__dirname, 'fixture/fail-fast/without-error/a.js'),
410+
path.join(__dirname, 'fixture/fail-fast/without-error/b.js')
411+
])
412+
.then(result => {
413+
t.ok(api.options.failFast);
414+
t.is(result.passCount, 2);
415+
t.is(result.failCount, 0);
416+
});
417+
});
418+
388419
test('serial execution mode', t => {
389420
const api = apiCreator({
390421
serial: true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import test from '../../../..';
2+
3+
test('pass', t => t.pass());
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import test from '../../../..';
2+
3+
setTimeout(() => {
4+
test.serial('pass', t => t.pass());
5+
}, 2000);

0 commit comments

Comments
 (0)