From c8644346574472e1f3d2eb3bc734d0a4273f0de8 Mon Sep 17 00:00:00 2001 From: Kory Nunn Date: Mon, 11 Jan 2016 10:31:50 +1000 Subject: [PATCH 1/2] [Fix] Resolves issue where tests would not attempt to complete --- lib/results.js | 14 +++++++++++--- package.json | 1 + test/async.js | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 test/async.js diff --git a/lib/results.js b/lib/results.js index 37bb1917..ab7850a4 100644 --- a/lib/results.js +++ b/lib/results.js @@ -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'); @@ -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() { @@ -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) { diff --git a/package.json b/package.json index 21e14946..6e082960 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/async.js b/test/async.js new file mode 100644 index 00000000..d9167652 --- /dev/null +++ b/test/async.js @@ -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(); + }); + }); +}); From 76ca27ffb712126347e46a02881cea04dbfffdc2 Mon Sep 17 00:00:00 2001 From: Kory Nunn Date: Thu, 10 Jan 2019 10:29:11 +1000 Subject: [PATCH 2/2] Ignore tape output. --- test/async.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/async.js b/test/async.js index d9167652..f643b5ad 100644 --- a/test/async.js +++ b/test/async.js @@ -1,13 +1,13 @@ 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(); - var tc = tap.createConsumer(); - test.createStream().pipe(tc); + test.createStream().pipe(concat(function(){})); // Ignore output function run1(callback){ test('first', function (t) {