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

Resolves issue where tests would not attempt to complete #236

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
14 changes: 11 additions & 3 deletions lib/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var through = require('through');
var resumer = require('resumer');
var inspect = require('object-inspect');
var callBound = require('call-bind/callBound');
var debounce = require('debounce');
var has = require('has');
var regexpTest = callBound('RegExp.prototype.test');
var $split = callBound('String.prototype.split');
Expand Down Expand Up @@ -81,6 +82,14 @@ Results.prototype.createStream = function (opts) {
self._stream.pipe(output);
}

self._end();

return output;
};

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

if (!this._isRunning) {
this._isRunning = true;
nextTick(function next() {
Expand All @@ -92,15 +101,14 @@ Results.prototype.createStream = function (opts) {
self.emit('done');
});
}

return output;
};
}, 1);

Results.prototype.push = function (t) {
var self = this;
$push(self.tests, 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 @@ -23,6 +23,7 @@
},
"dependencies": {
"call-bind": "^1.0.0",
"debounce": "^1.2.0",
"deep-equal": "^2.0.5",
"defined": "^1.0.0",
"dotignore": "^0.1.2",
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');
var concat = require('concat-stream');

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

var test = tape.createHarness();

test.createStream().pipe(concat(function(){})); // Ignore output

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();
});
});
});