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

tape

Package Overview
Dependencies
Maintainers
4
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 4.6.3 to 4.7.0

test/common.js

3

lib/default_stream.js

@@ -24,4 +24,3 @@ var through = require('through');

catch (e) { stream.emit('error', e) }
}
else {
} else {
try { console.log(line) }

@@ -28,0 +27,0 @@ catch (e) { stream.emit('error', e) }

@@ -0,1 +1,2 @@

var defined = require('defined');
var EventEmitter = require('events').EventEmitter;

@@ -61,4 +62,3 @@ var inherits = require('inherits');

self.on('done', function () { output.queue(null) });
}
else {
} else {
output = resumer();

@@ -152,4 +152,3 @@ output.queue('TAP version 13\n');

output += inner + 'actual: |-\n' + inner + ' ' + ac + '\n';
}
else {
} else {
output += inner + 'expected: ' + ex + '\n';

@@ -162,4 +161,8 @@ output += inner + 'actual: ' + ac + '\n';

}
if (res.operator === 'error' && res.actual && res.actual.stack) {
var lines = String(res.actual.stack).split('\n');
var actualStack = res.actual && res.actual.stack;
var errorStack = res.error && res.error.stack;
var stack = defined(actualStack, errorStack);
if (stack) {
var lines = String(stack).split('\n');
output += inner + 'stack: |-\n';

@@ -166,0 +169,0 @@ for (var i = 0; i < lines.length; i++) {

@@ -32,7 +32,5 @@ var deepEqual = require('deep-equal');

name = arg;
}
else if (t === 'object') {
} else if (t === 'object') {
opts = arg || opts;
}
else if (t === 'function') {
} else if (t === 'function') {
cb = arg;

@@ -70,3 +68,3 @@ }

}
else return val;
return val;
})(this, this[prop]);

@@ -181,4 +179,3 @@ }

});
}
else if (!this.ended) {
} else if (!this.ended) {
this.fail('test exited without ending', {

@@ -194,5 +191,3 @@ exiting: true

}
else {
return this._plan - (this._progeny.length + this.assertCount);
}
return this._plan - (this._progeny.length + this.assertCount);
};

@@ -199,0 +194,0 @@

{
"name": "tape",
"version": "4.6.3",
"version": "4.7.0",
"description": "tap-producing test harness for node and browsers",

@@ -16,8 +16,8 @@ "main": "index.js",

"function-bind": "~1.1.0",
"glob": "~7.1.1",
"glob": "~7.1.2",
"has": "~1.0.1",
"inherits": "~2.0.3",
"minimist": "~1.2.0",
"object-inspect": "~1.2.1",
"resolve": "~1.1.7",
"object-inspect": "~1.2.2",
"resolve": "~1.3.3",
"resumer": "~0.0.0",

@@ -28,6 +28,6 @@ "string.prototype.trim": "~1.1.2",

"devDependencies": {
"concat-stream": "~1.5.2",
"falafel": "~2.0.0",
"js-yaml": "~3.7.0",
"tap": "~7.1.1",
"concat-stream": "~1.6.0",
"falafel": "~2.1.0",
"js-yaml": "~3.8.4",
"tap": "~8.0.1",
"tap-parser": "~3.0.4"

@@ -34,0 +34,0 @@ },

@@ -5,2 +5,4 @@ var tape = require('../');

var stripFullStack = require('./common').stripFullStack;
tap.test('circular test', function (assert) {

@@ -12,3 +14,3 @@ var test = tape.createHarness({ exit : false });

assert.equal(
body.toString('utf8'),
stripFullStack(body.toString('utf8')),
'TAP version 13\n'

@@ -23,2 +25,7 @@ + '# circular\n'

+ ' { circular: [Circular] }\n'
+ ' stack: |-\n'
+ ' Error: should be equal\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/circular-things.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'

@@ -25,0 +32,0 @@ + '\n'

@@ -5,4 +5,7 @@ var tape = require('../');

var tapParser = require('tap-parser');
var yaml = require('js-yaml');
var common = require('./common');
var getDiag = common.getDiag;
var stripFullStack = common.stripFullStack;
tap.test('deep equal failure', function (assert) {

@@ -17,3 +20,3 @@ var test = tape.createHarness({ exit : false });

assert.equal(
body.toString('utf8'),
stripFullStack(body.toString('utf8')),
'TAP version 13\n'

@@ -28,2 +31,7 @@ + '# deep equal\n'

+ ' { a: 1 }\n'
+ ' stack: |-\n'
+ ' Error: should be equal\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'

@@ -45,2 +53,3 @@ + '\n'

parser.once('assert', function (data) {
delete data.diag.stack;
assert.deepEqual(data, {

@@ -73,3 +82,3 @@ ok: false,

assert.equal(
body.toString('utf8'),
stripFullStack(body.toString('utf8')),
'TAP version 13\n'

@@ -84,2 +93,7 @@ + '# deep equal\n'

+ ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }\n'
+ ' stack: |-\n'
+ ' Error: should be equal\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'

@@ -101,2 +115,3 @@ + '\n'

parser.once('assert', function (data) {
delete data.diag.stack;
assert.deepEqual(data, {

@@ -129,3 +144,3 @@ ok: false,

assert.equal(
body.toString('utf8'),
stripFullStack(body.toString('utf8')),
'TAP version 13\n'

@@ -140,2 +155,7 @@ + '# deep equal\n'

+ ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n'
+ ' stack: |-\n'
+ ' Error: should be equal\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'

@@ -157,2 +177,3 @@ + '\n'

parser.once('assert', function (data) {
delete data.diag.stack;
assert.deepEqual(data, {

@@ -175,11 +196,1 @@ ok: false,

})
function getDiag (body) {
var yamlStart = body.indexOf(' ---');
var yamlEnd = body.indexOf(' ...\n');
var diag = body.slice(yamlStart, yamlEnd).split('\n').map(function (line) {
return line.slice(2);
}).join('\n');
return yaml.safeLoad(diag);
}

@@ -6,2 +6,4 @@ var test = require('tap').test;

var stripFullStack = require('./common').stripFullStack;
test(function (t) {

@@ -14,3 +16,25 @@ t.plan(2);

ps.stdout.pipe(concat(function (body) {
t.equal(body.toString('utf8'), [
// The implementation of node's timer library has changed over time. We
// need to reverse engineer the error we expect to see.
// This code is unfortunately by necessity highly coupled to node
// versions, and may require tweaking with future versions of the timers
// library.
function doEnd() { throw new Error() };
var to = setTimeout(doEnd, 5000);
clearTimeout(to);
to._onTimeout = doEnd;
var stackExpected;
try {
to._onTimeout();
}
catch (e) {
stackExpected = stripFullStack(e.stack).split('\n')[1];
stackExpected = stackExpected.replace('double_end.js', 'double_end/double.js');
stackExpected = stackExpected.trim();
}
var stripped = stripFullStack(body.toString('utf8'));
t.equal(stripped, [
'TAP version 13',

@@ -22,2 +46,7 @@ '# double end',

' operator: fail',
' stack: |-',
' Error: .end() called twice',
' [... stack stripped ...]',
' ' + stackExpected,
' [... stack stripped ...]',
' ...',

@@ -24,0 +53,0 @@ '',

var test = require('../../');
test('double end', function (t) {
function doEnd() {
t.end();
}
t.equal(1 + 1, 2);
t.end();
setTimeout(function () {
t.end();
}, 5);
setTimeout(doEnd, 5);
});

@@ -6,2 +6,4 @@ var tap = require('tap');

var stripFullStack = require('./common').stripFullStack;
tap.test('exit ok', function (t) {

@@ -42,3 +44,3 @@ t.plan(2);

var tc = function (rows) {
t.same(rows.toString('utf8'), [
t.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',

@@ -55,2 +57,10 @@ '# array',

' actual: [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]',
' stack: |-',
' Error: should be equivalent',
' [... stack stripped ...]',
' at $TEST/exit/fail.js:$LINE:$COL',
' at eval (eval at <anonymous> ($TEST/exit/fail.js:$LINE:$COL))',
' at eval (eval at <anonymous> ($TEST/exit/fail.js:$LINE:$COL))',
' at Test.<anonymous> ($TEST/exit/fail.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',

@@ -76,3 +86,3 @@ '',

var tc = function (rows) {
t.same(rows.toString('utf8'), [
t.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',

@@ -90,2 +100,5 @@ '# array',

' actual: 5',
' stack: |-',
' Error: plan != count',
' [... stack stripped ...]',
' ...',

@@ -111,3 +124,3 @@ '',

var tc = function (rows) {
t.same(rows.toString('utf8'), [
t.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',

@@ -123,2 +136,5 @@ '# first',

' actual: 1',
' stack: |-',
' Error: plan != count',
' [... stack stripped ...]',
' ...',

@@ -125,0 +141,0 @@ '',

@@ -6,2 +6,4 @@ var falafel = require('falafel');

var stripFullStack = require('./common').stripFullStack;
tap.test('array test', function (tt) {

@@ -12,3 +14,3 @@ tt.plan(1);

var tc = function (rows) {
tt.same(rows.toString('utf8'), [
tt.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',

@@ -25,2 +27,10 @@ '# array',

' actual: [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]',
' stack: |-',
' Error: should be equivalent',
' [... stack stripped ...]',
' at $TEST/fail.js:$LINE:$COL',
' at eval (eval at <anonymous> ($TEST/fail.js:$LINE:$COL))',
' at eval (eval at <anonymous> ($TEST/fail.js:$LINE:$COL))',
' at Test.<anonymous> ($TEST/fail.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',

@@ -27,0 +37,0 @@ '',

@@ -69,2 +69,63 @@ var tape = require('../');

tap.test('preserves stack trace for failed assertions', function (tt) {
tt.plan(5);
var test = tape.createHarness();
var stream = test.createStream();
var parser = stream.pipe(tapParser());
var stack = ''
parser.once('assert', function (data) {
tt.equal(typeof data.diag.stack, 'string')
stack = data.diag.stack || ''
tt.ok(/^Error: false should be true(\n at .+)+/.exec(stack), 'stack should be a stack')
tt.deepEqual(data, {
ok: false,
id: 1,
name: "false should be true",
diag: {
stack: stack,
operator: 'equal',
expected: false,
actual: true
}
});
});
stream.pipe(concat(function (body) {
var body = body.toString('utf8')
tt.equal(
body,
'TAP version 13\n'
+ '# t.equal stack trace\n'
+ 'not ok 1 false should be true\n'
+ ' ---\n'
+ ' operator: equal\n'
+ ' expected: false\n'
+ ' actual: true\n'
+ ' stack: |-\n'
+ ' '
+ stack.replace(/\n/g, '\n ') + '\n'
+ ' ...\n'
+ '\n'
+ '1..1\n'
+ '# tests 1\n'
+ '# pass 0\n'
+ '# fail 1\n'
);
tt.deepEqual(getDiag(body), {
stack: stack,
operator: 'equal',
expected: false,
actual: true
});
}));
test('t.equal stack trace', function (t) {
t.plan(1);
t.equal(true, false, 'false should be true');
});
});
function getDiag (body) {

@@ -71,0 +132,0 @@ var yamlStart = body.indexOf(' ---');

@@ -5,2 +5,4 @@ var tape = require('../');

var stripFullStack = require('./common').stripFullStack;
function fn() {

@@ -18,2 +20,10 @@ throw new TypeError('RegExp');

var getter = function () { return 'message'; };
var messageGetterError = Object.defineProperty(
{ custom: 'error' },
'message',
{ configurable: true, enumerable: true, get: getter }
);
var thrower = function () { throw messageGetterError; };
tap.test('failures', function (tt) {

@@ -25,3 +35,3 @@ tt.plan(1);

tt.equal(
body.toString('utf8'),
stripFullStack(body.toString('utf8')),
'TAP version 13\n'

@@ -36,2 +46,7 @@ + '# non functions\n'

+ " { [TypeError: " + getNonFunctionMessage() + "] message: '" + getNonFunctionMessage() + "' }\n"
+ ' stack: |-\n'
+ ' TypeError: ' + getNonFunctionMessage(undefined) + '\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/throws.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'

@@ -45,2 +60,7 @@ + 'not ok 2 should throw\n'

+ " { [TypeError: " + getNonFunctionMessage(null) + "] message: '" + getNonFunctionMessage(null) + "' }\n"
+ ' stack: |-\n'
+ ' TypeError: ' + getNonFunctionMessage(null) + '\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/throws.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'

@@ -54,2 +74,7 @@ + 'not ok 3 should throw\n'

+ " { [TypeError: " + getNonFunctionMessage(true) + "] message: '" + getNonFunctionMessage(true) + "' }\n"
+ ' stack: |-\n'
+ ' TypeError: ' + getNonFunctionMessage(true) + '\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/throws.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'

@@ -63,2 +88,7 @@ + 'not ok 4 should throw\n'

+ " { [TypeError: " + getNonFunctionMessage(false) + "] message: '" + getNonFunctionMessage(false) + "' }\n"
+ ' stack: |-\n'
+ ' TypeError: ' + getNonFunctionMessage(false) + '\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/throws.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'

@@ -72,2 +102,7 @@ + 'not ok 5 should throw\n'

+ " { [TypeError: " + getNonFunctionMessage('abc') + "] message: '" + getNonFunctionMessage('abc') + "' }\n"
+ ' stack: |-\n'
+ ' TypeError: ' + getNonFunctionMessage('abc') + '\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/throws.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'

@@ -81,2 +116,7 @@ + 'not ok 6 should throw\n'

+ " { [TypeError: " + getNonFunctionMessage(/a/g) + "] message: '" + getNonFunctionMessage(/a/g) + "' }\n"
+ ' stack: |-\n'
+ ' TypeError: ' + getNonFunctionMessage(/a/g) + '\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/throws.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'

@@ -90,2 +130,7 @@ + 'not ok 7 should throw\n'

+ " { [TypeError: " + getNonFunctionMessage([]) + "] message: '" + getNonFunctionMessage([]) + "' }\n"
+ ' stack: |-\n'
+ ' TypeError: ' + getNonFunctionMessage([]) + '\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/throws.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'

@@ -99,2 +144,7 @@ + 'not ok 8 should throw\n'

+ " { [TypeError: " + getNonFunctionMessage({}) + "] message: '" + getNonFunctionMessage({}) + "' }\n"
+ ' stack: |-\n'
+ ' TypeError: ' + getNonFunctionMessage({}) + '\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/throws.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'

@@ -107,2 +157,7 @@ + '# function\n'

+ ' actual: undefined\n'
+ ' stack: |-\n'
+ ' Error: should throw\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/throws.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'

@@ -141,10 +196,4 @@ + '# custom error messages\n'

t.plan(3);
var getter = function () { return 'message'; };
var messageGetterError = Object.defineProperty(
{ custom: 'error' },
'message',
{ configurable: true, enumerable: true, get: getter }
);
t.equal(Object.prototype.propertyIsEnumerable.call(messageGetterError, 'message'), true, '"message" is enumerable');
t.throws(function () { throw messageGetterError; }, "{ custom: 'error', message: 'message' }");
t.throws(thrower, "{ custom: 'error', message: 'message' }");
t.equal(Object.getOwnPropertyDescriptor(messageGetterError, 'message').get, getter, 'getter is still the same');

@@ -151,0 +200,0 @@ });

@@ -5,2 +5,4 @@ var tape = require('../');

var stripFullStack = require('./common').stripFullStack;
tap.test('timeoutAfter test', function (tt) {

@@ -11,3 +13,3 @@ tt.plan(1);

var tc = function (rows) {
tt.same(rows.toString('utf8'), [
tt.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',

@@ -18,2 +20,5 @@ '# timeoutAfter',

' operator: fail',
' stack: |-',
' Error: test timed out after 1ms',
' [... stack stripped ...]',
' ...',

@@ -20,0 +25,0 @@ '',

@@ -6,2 +6,4 @@ var falafel = require('falafel');

var stripFullStack = require('./common').stripFullStack;
tap.test('array test', function (tt) {

@@ -12,3 +14,3 @@ tt.plan(1);

var tc = function (rows) {
tt.same(rows.toString('utf8'), [
tt.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',

@@ -25,2 +27,10 @@ '# array',

' actual: 4',
' stack: |-',
' Error: plan != count',
' [... stack stripped ...]',
' at $TEST/too_many.js:$LINE:$COL',
' at eval (eval at <anonymous> ($TEST/too_many.js:$LINE:$COL))',
' at eval (eval at <anonymous> ($TEST/too_many.js:$LINE:$COL))',
' at Test.<anonymous> ($TEST/too_many.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',

@@ -27,0 +37,0 @@ 'ok 6 should be equivalent',

@@ -5,2 +5,4 @@ var tape = require('../');

var stripFullStack = require('./common').stripFullStack;
tap.test('array test', function (tt) {

@@ -12,3 +14,3 @@ tt.plan(1);

tt.equal(
body.toString('utf8'),
stripFullStack(body.toString('utf8')),
'TAP version 13\n'

@@ -23,2 +25,7 @@ + '# undef\n'

+ ' {}\n'
+ ' stack: |-\n'
+ ' Error: should be equivalent\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/undef.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'

@@ -25,0 +32,0 @@ + '\n'

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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