Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tape

Package Overview
Dependencies
Maintainers
1
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tape - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

test/exit/second.js

38

index.js

@@ -5,6 +5,2 @@ var createDefaultStream = require('./lib/default_stream');

exports = module.exports = createHarness();
exports.createHarness = createHarness;
exports.Test = Test;
var canEmitExit = typeof process !== 'undefined' && process

@@ -24,2 +20,8 @@ && typeof process.on === 'function'

exports = module.exports = createHarness();
exports.createHarness = createHarness;
exports.Test = Test;
var exitInterval;
function createHarness (conf_) {

@@ -34,7 +36,28 @@ var pending = [];

var out = new Render();
if (!conf_) conf_ = {};
var tests = [];
if (conf_.exit === false && exitInterval) clearInterval(exitInterval);
exitInterval = !exitInterval && conf_.exit !== false && canEmitExit
&& typeof process._getActiveHandles === 'function'
&& setInterval(function () {
if (process._getActiveHandles().length === 1) {
tests.forEach(function (t) { t._exit() });
}
}, 200);
var exitCode = 0;
var exit = function (c) { exitCode = c };
out.on('end', function () {
clearInterval(exitInterval);
if (canExit && conf_.exit !== false) process.exit(exitCode);
});
var test = function (name, conf, cb) {
count++;
var t = new Test(name, conf, cb);
if (!conf || typeof conf !== 'object') conf = conf_ || {};
tests.push(t);
if (!conf || typeof conf !== 'object') conf = conf_;

@@ -49,3 +72,3 @@ if (conf.exit !== false) {

if (!code && !t._ok && (!only || name === only)) {
process.exit(1);
exit(1);
}

@@ -82,2 +105,3 @@ });

});
t.on('result', function (r) { if (!r.ok) exitCode = 1 });

@@ -109,3 +133,3 @@ t.on('end', onend);

if (conf.exit !== false && canExit && !t._ok) {
process.exit(1);
exit(1);
}

@@ -112,0 +136,0 @@ });

2

package.json
{
"name" : "tape",
"version" : "0.3.1",
"version" : "0.3.2",
"description" : "tap-producing test harness for node and browsers",

@@ -5,0 +5,0 @@ "main" : "index.js",

@@ -109,1 +109,35 @@ var tap = require('tap');

});
tap.test('more planned in a second test', function (t) {
t.plan(2);
var tc = tap.createConsumer();
var rows = [];
tc.on('data', function (r) { rows.push(r) });
tc.on('end', function () {
var rs = rows.map(function (r) {
if (r && typeof r === 'object') {
return { id : r.id, ok : r.ok, name : r.name.trim() };
}
else return r;
});
t.same(rs, [
'TAP version 13',
'first',
{ id: 1, ok: true, name: '(unnamed assert)' },
'second',
{ id: 2, ok: true, name: '(unnamed assert)' },
{ id: 3, ok: false, name: 'plan != count' },
'tests 3',
'pass 2',
'fail 1'
]);
});
var ps = spawn(process.execPath, [ __dirname + '/exit/second.js' ]);
ps.stdout.pipe(tc);
ps.on('exit', function (code) {
t.notEqual(code, 0);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc