Skip to content

Commit

Permalink
[Fix] Resolves issue where tests would not attempt to complete
Browse files Browse the repository at this point in the history
  • Loading branch information
KoryNunn authored and ljharb committed Jan 11, 2016
1 parent d15bc4b commit ea17937
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var through = require('through');
var resumer = require('resumer');
var inspect = require('object-inspect');
var bind = require('function-bind');
var debounce = require('debounce');
var has = require('has');
var regexpTest = bind.call(Function.call, RegExp.prototype.test);
var yamlIndicators = /\:|\-|\?/;
Expand Down Expand Up @@ -65,6 +66,14 @@ Results.prototype.createStream = function (opts) {
self._stream.pipe(output);
}

self._end();

return output;
};

Results.prototype._end = debounce(function () {
var self = this;

nextTick(function next() {
var t;
while (t = getNextTest(self)) {
Expand All @@ -73,15 +82,14 @@ Results.prototype.createStream = function (opts) {
}
self.emit('done');
});

return output;
};
}, 1);

Results.prototype.push = function (t) {
var self = this;
self.tests.push(t);
self._watch(t);
self.emit('_push', t);
self._end();
};

Results.prototype.only = function (t) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"test": "test"
},
"dependencies": {
"debounce": "~1.0.0",
"deep-equal": "~1.0.1",
"defined": "~1.0.0",
"for-each": "~0.3.3",
Expand Down
37 changes: 37 additions & 0 deletions test/async.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var tape = require('../');
var tap = require('tap');

tap.test('async test calls', function (tt) {
tt.plan(1);

var test = tape.createHarness();
var tc = tap.createConsumer();

test.createStream().pipe(tc);

function run1(callback){
test('first', function (t) {
t.plan(1);

t.pass();

setTimeout(callback, 10);
});
}

function run2(callback){
test('second', function (t) {
t.plan(1);

t.pass();

setTimeout(callback, 10);
});
}

run1(function(){
run2(function(){
tt.pass();
});
});
});

0 comments on commit ea17937

Please sign in to comment.