From 07433333e14fd283ceed246795863d59576d3286 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 3 Jan 2021 14:01:58 -0800 Subject: [PATCH] [Tests] make `stripFullStack` output an array of lines, for better failure messages --- test/anonymous-fn.js | 5 +- test/async-await.js | 34 +-- test/circular-things.js | 48 ++-- test/common.js | 2 +- test/deep-equal-failure.js | 144 +++++------ test/default-messages.js | 7 +- test/double_end.js | 14 +- test/edge-cases.js | 451 +++++++++++++++++---------------- test/error.js | 37 +-- test/exit.js | 36 ++- test/fail.js | 2 +- test/has spaces.js | 2 +- test/ignore_from_gitignore.js | 6 +- test/match.js | 4 +- test/no_callback.js | 3 +- test/not-deep-equal-failure.js | 144 +++++------ test/not-equal-failure.js | 44 ++-- test/numerics.js | 279 ++++++++++---------- test/promise_fail.js | 14 +- test/skip_explanation.js | 4 +- test/throws.js | 187 +++++++------- test/timeoutAfter.js | 10 +- test/todo.js | 36 +-- test/todo_explanation.js | 4 +- test/todo_single.js | 36 +-- test/too_many.js | 5 +- test/undef.js | 48 ++-- 27 files changed, 814 insertions(+), 792 deletions(-) diff --git a/test/anonymous-fn.js b/test/anonymous-fn.js index 019241e6..9a73ed8a 100644 --- a/test/anonymous-fn.js +++ b/test/anonymous-fn.js @@ -32,8 +32,9 @@ tap.test('inside anonymous functions', function (tt) { '1..1', '# tests 1', '# pass 0', - '# fail 1' - ].join('\n') + '\n'); + '# fail 1', + '' + ]); }; test.createStream().pipe(concat(tc)); diff --git a/test/async-await.js b/test/async-await.js index 8fcbb642..c7a996d5 100644 --- a/test/async-await.js +++ b/test/async-await.js @@ -35,13 +35,11 @@ tap.test('async1', function (t) { tap.test('async2', function (t) { runProgram('async-await', 'async2.js', function (r) { var stdout = r.stdout.toString('utf8'); - var lines = stdout.split('\n'); - lines = lines.filter(function (line) { + var lines = stdout.split('\n').filter(function (line) { return !/^(\s+)at(\s+)$/.test(line); }); - stdout = lines.join('\n'); - t.same(stripFullStack(stdout), [ + t.same(stripFullStack(lines.join('\n')), [ 'TAP version 13', '# async2', 'ok 1 before await', @@ -60,8 +58,10 @@ tap.test('async2', function (t) { '1..2', '# tests 2', '# pass 1', - '# fail 1' - ].join('\n') + '\n\n'); + '# fail 1', + '', + '' + ]); t.same(r.exitCode, 1); t.same(r.stderr.toString('utf8'), ''); t.end(); @@ -107,8 +107,10 @@ tap.test('async4', function (t) { '1..2', '# tests 2', '# pass 1', - '# fail 1' - ].join('\n') + '\n\n'); + '# fail 1', + '', + '' + ]); t.same(r.exitCode, 1); t.same(r.stderr.toString('utf8'), ''); t.end(); @@ -159,8 +161,10 @@ tap.test('async5', function (t) { '1..8', '# tests 8', '# pass 5', - '# fail 3' - ].join('\n') + '\n\n'); + '# fail 3', + '', + '' + ]); t.same(r.exitCode, 1); t.same(r.stderr.toString('utf8'), ''); t.end(); @@ -174,7 +178,7 @@ tap.test('sync-error', function (t) { '# sync-error', 'ok 1 before throw', '' - ].join('\n')); + ]); t.same(r.exitCode, 1); var stderr = r.stderr.toString('utf8'); @@ -197,7 +201,7 @@ tap.test('sync-error', function (t) { ' at Test.run ($TAPE/lib/test.js:$LINE:$COL)', ' at Test.bound [as run] ($TAPE/lib/test.js:$LINE:$COL)', '' - ].join('\n')); + ]); t.end(); }); }); @@ -211,7 +215,7 @@ tap.test('async-error', function (t) { }); stdout = lines.join('\n'); - t.same(stripFullStack(stdout.toString('utf8')), [ + t.same(stripFullStack(stdout), [ 'TAP version 13', '# async-error', 'ok 1 before throw', @@ -230,7 +234,7 @@ tap.test('async-error', function (t) { '# fail 1', '', '', - ].join('\n')); + ]); t.same(r.exitCode, 1); var stderr = r.stderr.toString('utf8'); @@ -276,7 +280,7 @@ tap.test('async-bug', function (t) { '# fail 1', '', '', - ].join('\n')); + ]); t.same(r.exitCode, 1); var stderr = r.stderr.toString('utf8'); diff --git a/test/circular-things.js b/test/circular-things.js index 0e4f3615..37786b51 100644 --- a/test/circular-things.js +++ b/test/circular-things.js @@ -11,30 +11,30 @@ tap.test('circular test', function (assert) { assert.plan(1); test.createStream().pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# circular\n' - + 'not ok 1 should be strictly equal\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: |-\n' - + ' {}\n' - + ' actual: |-\n' - + ' { circular: [Circular] }\n' - + ' at: Test. ($TEST/circular-things.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should be strictly equal\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/circular-things.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.deepEqual(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# circular', + 'not ok 1 should be strictly equal', + ' ---', + ' operator: equal', + ' expected: |-', + ' {}', + ' actual: |-', + ' { circular: [Circular] }', + ' at: Test. ($TEST/circular-things.js:$LINE:$COL)', + ' stack: |-', + ' Error: should be strictly equal', + ' [... stack stripped ...]', + ' at Test. ($TEST/circular-things.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); })); test('circular', function (t) { diff --git a/test/common.js b/test/common.js index 6afaa9e9..cb022ff0 100644 --- a/test/common.js +++ b/test/common.js @@ -69,7 +69,7 @@ module.exports.stripFullStack = function (output) { // Handle stack trace variation in Node v0.8 /at(:?) Test\.(?:module\.exports|tap\.test\.err\.code)/g, 'at$1 Test.' - ); + ).split('\n'); }; module.exports.runProgram = function (folderName, fileName, cb) { diff --git a/test/deep-equal-failure.js b/test/deep-equal-failure.js index 19c122de..d5f1bc74 100644 --- a/test/deep-equal-failure.js +++ b/test/deep-equal-failure.js @@ -17,30 +17,30 @@ tap.test('deep equal failure', function (assert) { stream.pipe(parser); stream.pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# deep equal\n' - + 'not ok 1 should be strictly equal\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: |-\n' - + ' { b: 2 }\n' - + ' actual: |-\n' - + ' { a: 1 }\n' - + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should be strictly equal\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.deepEqual(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# deep equal', + 'not ok 1 should be strictly equal', + ' ---', + ' operator: equal', + ' expected: |-', + ' { b: 2 }', + ' actual: |-', + ' { a: 1 }', + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)', + ' stack: |-', + ' Error: should be strictly equal', + ' [... stack stripped ...]', + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); assert.deepEqual(getDiag(body), { operator: 'equal', @@ -78,30 +78,30 @@ tap.test('deep equal failure, depth 6, with option', function (assert) { stream.pipe(parser); stream.pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# deep equal\n' - + 'not ok 1 should be strictly equal\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: |-\n' - + ' { a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }\n' - + ' actual: |-\n' - + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }\n' - + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should be strictly equal\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.deepEqual(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# deep equal', + 'not ok 1 should be strictly equal', + ' ---', + ' operator: equal', + ' expected: |-', + ' { a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }', + ' actual: |-', + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }', + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)', + ' stack: |-', + ' Error: should be strictly equal', + ' [... stack stripped ...]', + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); assert.deepEqual(getDiag(body), { operator: 'equal', @@ -139,30 +139,30 @@ tap.test('deep equal failure, depth 6, without option', function (assert) { stream.pipe(parser); stream.pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# deep equal\n' - + 'not ok 1 should be strictly equal\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: |-\n' - + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n' - + ' actual: |-\n' - + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n' - + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should be strictly equal\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.deepEqual(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# deep equal', + 'not ok 1 should be strictly equal', + ' ---', + ' operator: equal', + ' expected: |-', + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }', + ' actual: |-', + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }', + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)', + ' stack: |-', + ' Error: should be strictly equal', + ' [... stack stripped ...]', + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); assert.deepEqual(getDiag(body), { operator: 'equal', diff --git a/test/default-messages.js b/test/default-messages.js index 359c98a5..70d113bb 100644 --- a/test/default-messages.js +++ b/test/default-messages.js @@ -13,7 +13,6 @@ tap.test('default messages', function (t) { var ps = spawn(process.execPath, [path.join(__dirname, 'messages', 'defaults.js')]); ps.stdout.pipe(concat(function (rows) { - t.same(stripFullStack(rows.toString('utf8')), [ 'TAP version 13', '# default messages', @@ -44,7 +43,9 @@ tap.test('default messages', function (t) { '1..12', '# tests 12', '# pass 11', - '# fail 1' - ].join('\n') + '\n\n'); + '# fail 1', + '', + '' + ]); })); }); diff --git a/test/double_end.js b/test/double_end.js index 5dc6e2a0..23d6dc7c 100644 --- a/test/double_end.js +++ b/test/double_end.js @@ -7,11 +7,11 @@ var spawn = require('child_process').spawn; var stripFullStack = require('./common').stripFullStack; -test(function (t) { - t.plan(2); +test(function (tt) { + tt.plan(2); var ps = spawn(process.execPath, [path.join(__dirname, 'double_end', 'double.js')]); ps.on('exit', function (code) { - t.equal(code, 1); + tt.equal(code, 1); }); ps.stdout.pipe(concat(function (body) { // The implementation of node's timer library has changed over time. We @@ -31,14 +31,14 @@ test(function (t) { to._onTimeout(); } catch (e) { - stackExpected = stripFullStack(e.stack).split('\n')[1]; + stackExpected = stripFullStack(e.stack)[1]; stackExpected = stackExpected.replace('double_end.js', 'double_end/double.js'); stackExpected = stackExpected.trim(); atExpected = stackExpected.replace(/^at\s+/, 'at: '); } var stripped = stripFullStack(body.toString('utf8')); - t.equal(stripped, [ + tt.same(stripped, [ 'TAP version 13', '# double end', 'ok 1 should be strictly equal', @@ -57,6 +57,8 @@ test(function (t) { '# tests 2', '# pass 1', '# fail 1', - ].join('\n') + '\n\n'); + '', + '' + ]); })); }); diff --git a/test/edge-cases.js b/test/edge-cases.js index 93b6fceb..bf4f2e37 100644 --- a/test/edge-cases.js +++ b/test/edge-cases.js @@ -11,231 +11,232 @@ tap.test('edge cases', function (tt) { var test = tape.createHarness(); test.createStream().pipe(concat(function (body) { - tt.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# zeroes\n' - + 'not ok 1 0 equal to -0\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: |-\n' - + ' -0\n' - + ' actual: |-\n' - + ' 0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: 0 equal to -0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 2 -0 equal to 0\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: |-\n' - + ' 0\n' - + ' actual: |-\n' - + ' -0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: -0 equal to 0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 3 0 notEqual to -0\n' - + 'ok 4 -0 notEqual to 0\n' - + 'ok 5 0 looseEqual to -0\n' - + 'ok 6 -0 looseEqual to 0\n' - + 'not ok 7 0 notLooseEqual to -0\n' - + ' ---\n' - + ' operator: notLooseEqual\n' - + ' expected: |-\n' - + ' -0\n' - + ' actual: |-\n' - + ' 0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: 0 notLooseEqual to -0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 8 -0 notLooseEqual to 0\n' - + ' ---\n' - + ' operator: notLooseEqual\n' - + ' expected: |-\n' - + ' 0\n' - + ' actual: |-\n' - + ' -0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: -0 notLooseEqual to 0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 9 0 strictEqual to -0\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: |-\n' - + ' -0\n' - + ' actual: |-\n' - + ' 0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: 0 strictEqual to -0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 10 -0 strictEqual to 0\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: |-\n' - + ' 0\n' - + ' actual: |-\n' - + ' -0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: -0 strictEqual to 0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 11 0 notStrictEqual to -0\n' - + 'ok 12 -0 notStrictEqual to 0\n' - + 'ok 13 0 deepLooseEqual to -0\n' - + 'ok 14 -0 deepLooseEqual to 0\n' - + 'not ok 15 0 notDeepLooseEqual to -0\n' - + ' ---\n' - + ' operator: notDeepLooseEqual\n' - + ' expected: |-\n' - + ' -0\n' - + ' actual: |-\n' - + ' 0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: 0 notDeepLooseEqual to -0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 16 -0 notDeepLooseEqual to 0\n' - + ' ---\n' - + ' operator: notDeepLooseEqual\n' - + ' expected: |-\n' - + ' 0\n' - + ' actual: |-\n' - + ' -0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: -0 notDeepLooseEqual to 0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 17 0 deepEqual to -0\n' - + ' ---\n' - + ' operator: deepEqual\n' - + ' expected: |-\n' - + ' -0\n' - + ' actual: |-\n' - + ' 0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: 0 deepEqual to -0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 18 -0 deepEqual to 0\n' - + ' ---\n' - + ' operator: deepEqual\n' - + ' expected: |-\n' - + ' 0\n' - + ' actual: |-\n' - + ' -0\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: -0 deepEqual to 0\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 19 0 notDeepEqual to -0\n' - + 'ok 20 -0 notDeepEqual to 0\n' - + '# NaNs\n' - + 'ok 21 NaN equal to NaN\n' - + 'not ok 22 NaN notEqual to NaN\n' - + ' ---\n' - + ' operator: notEqual\n' - + ' expected: NaN\n' - + ' actual: NaN\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: NaN notEqual to NaN\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 23 NaN looseEqual to NaN\n' - + ' ---\n' - + ' operator: looseEqual\n' - + ' expected: NaN\n' - + ' actual: NaN\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: NaN looseEqual to NaN\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 24 NaN notLooseEqual to NaN\n' - + 'ok 25 NaN strictEqual to NaN\n' - + 'not ok 26 NaN notStrictEqual to NaN\n' - + ' ---\n' - + ' operator: notEqual\n' - + ' expected: NaN\n' - + ' actual: NaN\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: NaN notStrictEqual to NaN\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 27 NaN deepLooseEqual to NaN\n' - + ' ---\n' - + ' operator: deepLooseEqual\n' - + ' expected: NaN\n' - + ' actual: NaN\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: NaN deepLooseEqual to NaN\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 28 NaN notDeepLooseEqual to NaN\n' - + 'ok 29 NaN deepEqual to NaN\n' - + 'not ok 30 NaN notDeepEqual to NaN\n' - + ' ---\n' - + ' operator: notDeepEqual\n' - + ' expected: NaN\n' - + ' actual: NaN\n' - + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: NaN notDeepEqual to NaN\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n1..30\n' - + '# tests 30\n' - + '# pass 15\n' - + '# fail 15\n' - ); + tt.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# zeroes', + 'not ok 1 0 equal to -0', + ' ---', + ' operator: equal', + ' expected: |-', + ' -0', + ' actual: |-', + ' 0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: 0 equal to -0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 2 -0 equal to 0', + ' ---', + ' operator: equal', + ' expected: |-', + ' 0', + ' actual: |-', + ' -0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: -0 equal to 0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 3 0 notEqual to -0', + 'ok 4 -0 notEqual to 0', + 'ok 5 0 looseEqual to -0', + 'ok 6 -0 looseEqual to 0', + 'not ok 7 0 notLooseEqual to -0', + ' ---', + ' operator: notLooseEqual', + ' expected: |-', + ' -0', + ' actual: |-', + ' 0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: 0 notLooseEqual to -0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 8 -0 notLooseEqual to 0', + ' ---', + ' operator: notLooseEqual', + ' expected: |-', + ' 0', + ' actual: |-', + ' -0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: -0 notLooseEqual to 0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 9 0 strictEqual to -0', + ' ---', + ' operator: equal', + ' expected: |-', + ' -0', + ' actual: |-', + ' 0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: 0 strictEqual to -0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 10 -0 strictEqual to 0', + ' ---', + ' operator: equal', + ' expected: |-', + ' 0', + ' actual: |-', + ' -0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: -0 strictEqual to 0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 11 0 notStrictEqual to -0', + 'ok 12 -0 notStrictEqual to 0', + 'ok 13 0 deepLooseEqual to -0', + 'ok 14 -0 deepLooseEqual to 0', + 'not ok 15 0 notDeepLooseEqual to -0', + ' ---', + ' operator: notDeepLooseEqual', + ' expected: |-', + ' -0', + ' actual: |-', + ' 0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: 0 notDeepLooseEqual to -0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 16 -0 notDeepLooseEqual to 0', + ' ---', + ' operator: notDeepLooseEqual', + ' expected: |-', + ' 0', + ' actual: |-', + ' -0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: -0 notDeepLooseEqual to 0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 17 0 deepEqual to -0', + ' ---', + ' operator: deepEqual', + ' expected: |-', + ' -0', + ' actual: |-', + ' 0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: 0 deepEqual to -0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 18 -0 deepEqual to 0', + ' ---', + ' operator: deepEqual', + ' expected: |-', + ' 0', + ' actual: |-', + ' -0', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: -0 deepEqual to 0', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 19 0 notDeepEqual to -0', + 'ok 20 -0 notDeepEqual to 0', + '# NaNs', + 'ok 21 NaN equal to NaN', + 'not ok 22 NaN notEqual to NaN', + ' ---', + ' operator: notEqual', + ' expected: NaN', + ' actual: NaN', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: NaN notEqual to NaN', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 23 NaN looseEqual to NaN', + ' ---', + ' operator: looseEqual', + ' expected: NaN', + ' actual: NaN', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: NaN looseEqual to NaN', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 24 NaN notLooseEqual to NaN', + 'ok 25 NaN strictEqual to NaN', + 'not ok 26 NaN notStrictEqual to NaN', + ' ---', + ' operator: notEqual', + ' expected: NaN', + ' actual: NaN', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: NaN notStrictEqual to NaN', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 27 NaN deepLooseEqual to NaN', + ' ---', + ' operator: deepLooseEqual', + ' expected: NaN', + ' actual: NaN', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: NaN deepLooseEqual to NaN', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 28 NaN notDeepLooseEqual to NaN', + 'ok 29 NaN deepEqual to NaN', + 'not ok 30 NaN notDeepEqual to NaN', + ' ---', + ' operator: notDeepEqual', + ' expected: NaN', + ' actual: NaN', + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' stack: |-', + ' Error: NaN notDeepEqual to NaN', + ' [... stack stripped ...]', + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..30', + '# tests 30', + '# pass 15', + '# fail 15', + '' + ]); })); test('zeroes', function (t) { diff --git a/test/error.js b/test/error.js index 1d29c21d..7340e868 100644 --- a/test/error.js +++ b/test/error.js @@ -11,24 +11,25 @@ tap.test('failures', function (tt) { var test = tape.createHarness(); test.createStream().pipe(concat(function (body) { - tt.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# error\n' - + 'not ok 1 Error: this is a message\n' - + ' ---\n' - + ' operator: error\n' - + ' at: Test. ($TEST/error.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: this is a message\n' - + ' at Test. ($TEST/error.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + tt.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# error', + 'not ok 1 Error: this is a message', + ' ---', + ' operator: error', + ' at: Test. ($TEST/error.js:$LINE:$COL)', + ' stack: |-', + ' Error: this is a message', + ' at Test. ($TEST/error.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '', + ]); })); test('error', function (t) { diff --git a/test/exit.js b/test/exit.js index 098d76e9..d782b8f3 100644 --- a/test/exit.js +++ b/test/exit.js @@ -68,8 +68,10 @@ tap.test('exit fail', function (t) { '1..5', '# tests 5', '# pass 4', - '# fail 1' - ].join('\n') + '\n\n'); + '# fail 1', + '', + '' + ]); }; var ps = spawn(process.execPath, [path.join(__dirname, 'exit', 'fail.js')]); @@ -105,8 +107,10 @@ tap.test('too few exit', function (t) { '1..6', '# tests 6', '# pass 5', - '# fail 1' - ].join('\n') + '\n\n'); + '# fail 1', + '', + '' + ]); }; var ps = spawn(process.execPath, [path.join(__dirname, '/exit/too_few.js')]); @@ -140,8 +144,10 @@ tap.test('more planned in a second test', function (t) { '1..3', '# tests 3', '# pass 2', - '# fail 1' - ].join('\n') + '\n\n'); + '# fail 1', + '', + '' + ]); }; var ps = spawn(process.execPath, [path.join(__dirname, '/exit/second.js')]); @@ -164,8 +170,10 @@ tap.test('todo passing', function (t) { '# tests 1', '# pass 1', '', - '# ok' - ].join('\n') + '\n\n'); + '# ok', + '', + '' + ]); }; var ps = spawn(process.execPath, [path.join(__dirname, '/exit/todo.js')]); @@ -194,8 +202,10 @@ tap.test('todo failing', function (t) { '# tests 1', '# pass 1', '', - '# ok' - ].join('\n') + '\n\n'); + '# ok', + '', + '' + ]); }; var ps = spawn(process.execPath, [path.join(__dirname, '/exit/todo_fail.js')]); @@ -227,8 +237,10 @@ tap.test('forgot to call t.end()', function (t) { '1..3', '# tests 3', '# pass 2', - '# fail 1' - ].join('\n') + '\n\n'); + '# fail 1', + '', + '' + ]); }; var ps = spawn(process.execPath, [path.join(__dirname, '/exit/missing_end.js')]); diff --git a/test/fail.js b/test/fail.js index 2296fed2..1d0a312b 100644 --- a/test/fail.js +++ b/test/fail.js @@ -40,7 +40,7 @@ tap.test('array test', function (tt) { '# pass 4', '# fail 1', '' - ].join('\n')); + ]); }; test.createStream().pipe(concat(tc)); diff --git a/test/has spaces.js b/test/has spaces.js index a2afb320..990c9d88 100644 --- a/test/has spaces.js +++ b/test/has spaces.js @@ -30,7 +30,7 @@ tap.test('array test', function (tt) { '# pass 0', '# fail 1', '' - ].join('\n')); + ]); }; test.createStream().pipe(concat(tc)); diff --git a/test/ignore_from_gitignore.js b/test/ignore_from_gitignore.js index 16b076a4..d95260b8 100644 --- a/test/ignore_from_gitignore.js +++ b/test/ignore_from_gitignore.js @@ -35,7 +35,7 @@ tap.test('Should pass with ignoring', { skip: process.platform === 'win32' }, fu '# ok', '', '' - ].join('\n')); + ]); }; var ps = spawn(tapeBin, ['**/*.js', '-i', '.ignore'], {cwd: path.join(__dirname, 'ignore')}); @@ -92,7 +92,7 @@ tap.test('Should pass', { skip: process.platform === 'win32' }, function (tt) { '# fail 2', '', '' - ].join('\n')); + ]); }; var ps = spawn(tapeBin, ['**/*.js'], {cwd: path.join(__dirname, 'ignore')}); @@ -110,7 +110,7 @@ tap.test('Should fail when ignore file does not exist', { skip: process.platform }; var testStderr = function (rows) { - tt.ok(/^ENOENT[:,] no such file or directory,? (?:open )?'\$TEST\/ignore\/.gitignore'\n$/m.test(stripFullStack(rows.toString('utf8')))); + tt.ok(/^ENOENT[:,] no such file or directory,? (?:open )?'\$TEST\/ignore\/.gitignore'\n$/m.test(stripFullStack(rows.toString('utf8')).join('\n'))); }; var ps = spawn(tapeBin, ['**/*.js', '-i'], {cwd: path.join(__dirname, 'ignore')}); diff --git a/test/match.js b/test/match.js index 09ccd343..b598b9db 100644 --- a/test/match.js +++ b/test/match.js @@ -48,7 +48,7 @@ tap.test('match', function (tt) { '# pass 4', '# fail 2', '' - ].join('\n')); + ]); }; test.createStream().pipe(concat(tc)); @@ -142,7 +142,7 @@ tap.test('doesNotMatch', function (tt) { '# pass 2', '# fail 4', '' - ].join('\n')); + ]); }; test.createStream().pipe(concat(tc)); diff --git a/test/no_callback.js b/test/no_callback.js index 9369545d..646cbca0 100644 --- a/test/no_callback.js +++ b/test/no_callback.js @@ -31,7 +31,8 @@ tap.test('no callback', function (tt) { '# tests 1', '# pass 0', '# fail 1', - ].join('\n') + '\n'); + '', + ]); }; test.createStream().pipe(concat(tc)); diff --git a/test/not-deep-equal-failure.js b/test/not-deep-equal-failure.js index c34f20b8..dadfa535 100644 --- a/test/not-deep-equal-failure.js +++ b/test/not-deep-equal-failure.js @@ -17,30 +17,30 @@ tap.test('deep equal failure', function (assert) { stream.pipe(parser); stream.pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# not deep equal\n' - + 'not ok 1 should not be deeply equivalent\n' - + ' ---\n' - + ' operator: notDeepEqual\n' - + ' expected: |-\n' - + ' { b: 2 }\n' - + ' actual: |-\n' - + ' { b: 2 }\n' - + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should not be deeply equivalent\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.deepEqual(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# not deep equal', + 'not ok 1 should not be deeply equivalent', + ' ---', + ' operator: notDeepEqual', + ' expected: |-', + ' { b: 2 }', + ' actual: |-', + ' { b: 2 }', + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)', + ' stack: |-', + ' Error: should not be deeply equivalent', + ' [... stack stripped ...]', + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); assert.deepEqual(getDiag(body), { operator: 'notDeepEqual', @@ -78,30 +78,30 @@ tap.test('not deep equal failure, depth 6, with option', function (assert) { stream.pipe(parser); stream.pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# not deep equal\n' - + 'not ok 1 should not be deeply equivalent\n' - + ' ---\n' - + ' operator: notDeepEqual\n' - + ' expected: |-\n' - + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }\n' - + ' actual: |-\n' - + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }\n' - + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should not be deeply equivalent\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.deepEqual(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# not deep equal', + 'not ok 1 should not be deeply equivalent', + ' ---', + ' operator: notDeepEqual', + ' expected: |-', + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }', + ' actual: |-', + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }', + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)', + ' stack: |-', + ' Error: should not be deeply equivalent', + ' [... stack stripped ...]', + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); assert.deepEqual(getDiag(body), { operator: 'notDeepEqual', @@ -139,30 +139,30 @@ tap.test('not deep equal failure, depth 6, without option', function (assert) { stream.pipe(parser); stream.pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# not deep equal\n' - + 'not ok 1 should not be deeply equivalent\n' - + ' ---\n' - + ' operator: notDeepEqual\n' - + ' expected: |-\n' - + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n' - + ' actual: |-\n' - + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n' - + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should not be deeply equivalent\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.deepEqual(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# not deep equal', + 'not ok 1 should not be deeply equivalent', + ' ---', + ' operator: notDeepEqual', + ' expected: |-', + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }', + ' actual: |-', + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }', + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)', + ' stack: |-', + ' Error: should not be deeply equivalent', + ' [... stack stripped ...]', + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); assert.deepEqual(getDiag(body), { operator: 'notDeepEqual', diff --git a/test/not-equal-failure.js b/test/not-equal-failure.js index a706c2ef..4cf11f02 100644 --- a/test/not-equal-failure.js +++ b/test/not-equal-failure.js @@ -17,28 +17,28 @@ tap.test('not equal failure', function (assert) { stream.pipe(parser); stream.pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# not equal\n' - + 'not ok 1 should not be strictly equal\n' - + ' ---\n' - + ' operator: notEqual\n' - + ' expected: 2\n' - + ' actual: 2\n' - + ' at: Test. ($TEST/not-equal-failure.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should not be strictly equal\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/not-equal-failure.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + assert.deepEqual(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# not equal', + 'not ok 1 should not be strictly equal', + ' ---', + ' operator: notEqual', + ' expected: 2', + ' actual: 2', + ' at: Test. ($TEST/not-equal-failure.js:$LINE:$COL)', + ' stack: |-', + ' Error: should not be strictly equal', + ' [... stack stripped ...]', + ' at Test. ($TEST/not-equal-failure.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); assert.deepEqual(getDiag(body), { operator: 'notEqual', diff --git a/test/numerics.js b/test/numerics.js index a7a40204..746a5098 100644 --- a/test/numerics.js +++ b/test/numerics.js @@ -11,145 +11,146 @@ tap.test('numerics', function (tt) { var test = tape.createHarness(); test.createStream().pipe(concat(function (body) { - tt.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# numeric strings\n' - + 'not ok 1 number equal to string\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: \'3\'\n' - + ' actual: 3\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: number equal to string\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 2 string equal to number\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: 3\n' - + ' actual: \'3\'\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: string equal to number\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 3 number notEqual to string\n' - + 'ok 4 string notEqual to number\n' - + 'ok 5 number looseEqual to string\n' - + 'ok 6 string looseEqual to number\n' - + 'not ok 7 number notLooseEqual to string\n' - + ' ---\n' - + ' operator: notLooseEqual\n' - + ' expected: \'3\'\n' - + ' actual: 3\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: number notLooseEqual to string\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 8 string notLooseEqual to number\n' - + ' ---\n' - + ' operator: notLooseEqual\n' - + ' expected: 3\n' - + ' actual: \'3\'\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: string notLooseEqual to number\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 9 number strictEqual to string\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: \'3\'\n' - + ' actual: 3\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: number strictEqual to string\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 10 string strictEqual to number\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: 3\n' - + ' actual: \'3\'\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: string strictEqual to number\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 11 number notStrictEqual to string\n' - + 'ok 12 string notStrictEqual to number\n' - + 'ok 13 number deepLooseEqual to string\n' - + 'ok 14 string deepLooseEqual to number\n' - + 'not ok 15 number notDeepLooseEqual to string\n' - + ' ---\n' - + ' operator: notDeepLooseEqual\n' - + ' expected: \'3\'\n' - + ' actual: 3\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: number notDeepLooseEqual to string\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 16 string notDeepLooseEqual to number\n' - + ' ---\n' - + ' operator: notDeepLooseEqual\n' - + ' expected: 3\n' - + ' actual: \'3\'\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: string notDeepLooseEqual to number\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 17 number deepEqual to string\n' - + ' ---\n' - + ' operator: deepEqual\n' - + ' expected: \'3\'\n' - + ' actual: 3\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: number deepEqual to string\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'not ok 18 string deepEqual to number\n' - + ' ---\n' - + ' operator: deepEqual\n' - + ' expected: 3\n' - + ' actual: \'3\'\n' - + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: string deepEqual to number\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + 'ok 19 number notDeepEqual to string\n' - + 'ok 20 string notDeepEqual to number\n' - + '\n1..20\n' - + '# tests 20\n' - + '# pass 10\n' - + '# fail 10\n' - ); + tt.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# numeric strings', + 'not ok 1 number equal to string', + ' ---', + ' operator: equal', + ' expected: \'3\'', + ' actual: 3', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: number equal to string', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 2 string equal to number', + ' ---', + ' operator: equal', + ' expected: 3', + ' actual: \'3\'', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: string equal to number', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 3 number notEqual to string', + 'ok 4 string notEqual to number', + 'ok 5 number looseEqual to string', + 'ok 6 string looseEqual to number', + 'not ok 7 number notLooseEqual to string', + ' ---', + ' operator: notLooseEqual', + ' expected: \'3\'', + ' actual: 3', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: number notLooseEqual to string', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 8 string notLooseEqual to number', + ' ---', + ' operator: notLooseEqual', + ' expected: 3', + ' actual: \'3\'', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: string notLooseEqual to number', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 9 number strictEqual to string', + ' ---', + ' operator: equal', + ' expected: \'3\'', + ' actual: 3', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: number strictEqual to string', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 10 string strictEqual to number', + ' ---', + ' operator: equal', + ' expected: 3', + ' actual: \'3\'', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: string strictEqual to number', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 11 number notStrictEqual to string', + 'ok 12 string notStrictEqual to number', + 'ok 13 number deepLooseEqual to string', + 'ok 14 string deepLooseEqual to number', + 'not ok 15 number notDeepLooseEqual to string', + ' ---', + ' operator: notDeepLooseEqual', + ' expected: \'3\'', + ' actual: 3', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: number notDeepLooseEqual to string', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 16 string notDeepLooseEqual to number', + ' ---', + ' operator: notDeepLooseEqual', + ' expected: 3', + ' actual: \'3\'', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: string notDeepLooseEqual to number', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 17 number deepEqual to string', + ' ---', + ' operator: deepEqual', + ' expected: \'3\'', + ' actual: 3', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: number deepEqual to string', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'not ok 18 string deepEqual to number', + ' ---', + ' operator: deepEqual', + ' expected: 3', + ' actual: \'3\'', + ' at: Test. ($TEST/numerics.js:$LINE:$COL)', + ' stack: |-', + ' Error: string deepEqual to number', + ' [... stack stripped ...]', + ' at Test. ($TEST/numerics.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 19 number notDeepEqual to string', + 'ok 20 string notDeepEqual to number', + '', + '1..20', + '# tests 20', + '# pass 10', + '# fail 10', + '' + ]); })); test('numeric strings', function (t) { diff --git a/test/promise_fail.js b/test/promise_fail.js index 1aeb95d5..fc38fb75 100644 --- a/test/promise_fail.js +++ b/test/promise_fail.js @@ -19,12 +19,9 @@ tap.test('callback returning rejected promise should cause that test (and only t return tt.pass('the test file indicated it should be skipped'); } - var strippedString = stripFullStack(rowsString); - var lines = strippedString.split('\n'); - lines = lines.filter(function (line) { + var strippedString = stripFullStack(rowsString).filter(function (line) { return !/^(\s+)at(\s+)(?:Test\.)?(?:$|\s)/.test(line); - }); - strippedString = lines.join('\n'); + }).join('\n'); // hack for consistency across all versions of node // some versions produce a longer stack trace for some reason @@ -70,12 +67,9 @@ tap.test('subtest callback returning rejected promise should cause that subtest return tt.pass('the test file indicated it should be skipped'); } - var strippedString = stripFullStack(rowsString); - var lines = strippedString.split('\n'); - lines = lines.filter(function (line) { + var strippedString = stripFullStack(rowsString).filter(function (line) { return !/^(\s+)at(\s+)(?:Test\.)?(?:$|\s)/.test(line); - }); - strippedString = lines.join('\n'); + }).join('\n'); // hack for consistency across all versions of node // some versions produce a longer stack trace for some reason diff --git a/test/skip_explanation.js b/test/skip_explanation.js index 8409e21a..54c76883 100644 --- a/test/skip_explanation.js +++ b/test/skip_explanation.js @@ -9,7 +9,7 @@ tap.test('test skip explanations', function (assert) { assert.plan(1); var verify = function (output) { - assert.equal(stripFullStack(output.toString('utf8')), [ + assert.deepEqual(stripFullStack(output.toString('utf8')), [ 'TAP version 13', '# SKIP (this skips)', '# some tests might skip', @@ -32,7 +32,7 @@ tap.test('test skip explanations', function (assert) { '', '# ok', '' - ].join('\n')); + ]); }; var tapeTest = test.createHarness(); diff --git a/test/throws.js b/test/throws.js index bd90356a..70d90cef 100644 --- a/test/throws.js +++ b/test/throws.js @@ -33,99 +33,100 @@ tap.test('failures', function (tt) { var test = tape.createHarness(); test.createStream().pipe(concat(function (body) { - tt.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# non functions\n' - + 'ok 1 should throw\n' - + 'ok 2 should throw\n' - + 'ok 3 should throw\n' - + 'ok 4 should throw\n' - + 'ok 5 should throw\n' - + 'ok 6 should throw\n' - + 'ok 7 should throw\n' - + 'ok 8 should throw\n' - + '# function\n' - + 'not ok 9 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: undefined\n' - + ' actual: undefined\n' - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should throw\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '# custom error messages\n' - + 'ok 10 "message" is enumerable\n' - + "ok 11 { custom: 'error', message: 'message' }\n" - + 'ok 12 getter is still the same\n' - + '# throws null\n' - + 'ok 13 throws null\n' - + '# wrong type of error\n' - + 'not ok 14 throws actual\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' [Function: TypeError]\n' - + ' actual: |-\n' - + " { [RangeError: actual!] message: 'actual!' }\n" - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' RangeError: actual!\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '# object\n' - + 'ok 15 object properties are validated\n' - + '# object with regexes\n' - + 'ok 16 object with regex values is validated\n' - + '# similar error object\n' - + 'ok 17 throwing a similar error\n' - + '# validate with regex\n' - + 'ok 18 regex against toString of error\n' - + '# custom error validation\n' - + 'ok 19 error is SyntaxError\n' - + 'ok 20 error matches /value/\n' - + 'ok 21 unexpected error\n' - + '# throwing primitives\n' - + 'ok 22 primitive: null\n' - + 'ok 23 primitive: undefined\n' - + 'ok 24 primitive: 0\n' - + 'ok 25 primitive: NaN\n' - + 'ok 26 primitive: 42\n' - + 'ok 27 primitive: Infinity\n' - + 'ok 28 primitive: \'\'\n' - + 'ok 29 primitive: \'foo\'\n' - + 'ok 30 primitive: true\n' - + 'ok 31 primitive: false\n' - + '# ambiguous arguments\n' - + 'ok 32 Second\n' - + 'ok 33 Second\n' - + 'ok 34 Second\n' - + 'ok 35 should throw\n' - + 'not ok 36 should throw\n' - + ' ---\n' - + ' operator: throws\n' - + ' expected: |-\n' - + ' \'/Second$/\'\n' - + ' actual: |-\n' - + ' { [Error: First] message: \'First\' }\n' - + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: First\n' - + ' at throwingFirst ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/throws.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n1..36\n' - + '# tests 36\n' - + '# pass 33\n' - + '# fail 3\n' - ); + tt.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# non functions', + 'ok 1 should throw', + 'ok 2 should throw', + 'ok 3 should throw', + 'ok 4 should throw', + 'ok 5 should throw', + 'ok 6 should throw', + 'ok 7 should throw', + 'ok 8 should throw', + '# function', + 'not ok 9 should throw', + ' ---', + ' operator: throws', + ' expected: undefined', + ' actual: undefined', + ' at: Test. ($TEST/throws.js:$LINE:$COL)', + ' stack: |-', + ' Error: should throw', + ' [... stack stripped ...]', + ' at Test. ($TEST/throws.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '# custom error messages', + 'ok 10 "message" is enumerable', + "ok 11 { custom: 'error', message: 'message' }", + 'ok 12 getter is still the same', + '# throws null', + 'ok 13 throws null', + '# wrong type of error', + 'not ok 14 throws actual', + ' ---', + ' operator: throws', + ' expected: |-', + ' [Function: TypeError]', + ' actual: |-', + " { [RangeError: actual!] message: 'actual!' }", + ' at: Test. ($TEST/throws.js:$LINE:$COL)', + ' stack: |-', + ' RangeError: actual!', + ' at Test. ($TEST/throws.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '# object', + 'ok 15 object properties are validated', + '# object with regexes', + 'ok 16 object with regex values is validated', + '# similar error object', + 'ok 17 throwing a similar error', + '# validate with regex', + 'ok 18 regex against toString of error', + '# custom error validation', + 'ok 19 error is SyntaxError', + 'ok 20 error matches /value/', + 'ok 21 unexpected error', + '# throwing primitives', + 'ok 22 primitive: null', + 'ok 23 primitive: undefined', + 'ok 24 primitive: 0', + 'ok 25 primitive: NaN', + 'ok 26 primitive: 42', + 'ok 27 primitive: Infinity', + 'ok 28 primitive: \'\'', + 'ok 29 primitive: \'foo\'', + 'ok 30 primitive: true', + 'ok 31 primitive: false', + '# ambiguous arguments', + 'ok 32 Second', + 'ok 33 Second', + 'ok 34 Second', + 'ok 35 should throw', + 'not ok 36 should throw', + ' ---', + ' operator: throws', + ' expected: |-', + ' \'/Second$/\'', + ' actual: |-', + ' { [Error: First] message: \'First\' }', + ' at: Test. ($TEST/throws.js:$LINE:$COL)', + ' stack: |-', + ' Error: First', + ' at throwingFirst ($TEST/throws.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' at Test. ($TEST/throws.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..36', + '# tests 36', + '# pass 33', + '# fail 3', + '' + ]); })); test('non functions', function (t) { diff --git a/test/timeoutAfter.js b/test/timeoutAfter.js index 298a3d60..45f77096 100644 --- a/test/timeoutAfter.js +++ b/test/timeoutAfter.js @@ -25,8 +25,9 @@ tap.test('timeoutAfter test', function (tt) { '1..1', '# tests 1', '# pass 0', - '# fail 1' - ].join('\n') + '\n'); + '# fail 1', + '' + ]); }; test.createStream().pipe(concat(tc)); @@ -65,8 +66,9 @@ tap.test('timeoutAfter with Promises', { skip: typeof Promise === 'undefined' }, '1..2', '# tests 2', '# pass 0', - '# fail 2' - ].join('\n') + '\n'); + '# fail 2', + '' + ]); }; test.createStream().pipe(concat(tc)); diff --git a/test/todo.js b/test/todo.js index aa4798c4..f234b1cf 100644 --- a/test/todo.js +++ b/test/todo.js @@ -12,24 +12,24 @@ tap.test('tape todo test', function (assert) { assert.plan(1); test.createStream().pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# success\n' - + 'ok 1 this test runs\n' - + '# TODO failure\n' - + 'not ok 2 should never happen # TODO\n' - + ' ---\n' - + ' operator: fail\n' - + ' at: Test. ($TEST/todo.js:$LINE:$COL)\n' - + ' ...\n' - + '\n' - + '1..2\n' - + '# tests 2\n' - + '# pass 2\n' - + '\n' - + '# ok\n' - ); + assert.deepEqual(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# success', + 'ok 1 this test runs', + '# TODO failure', + 'not ok 2 should never happen # TODO', + ' ---', + ' operator: fail', + ' at: Test. ($TEST/todo.js:$LINE:$COL)', + ' ...', + '', + '1..2', + '# tests 2', + '# pass 2', + '', + '# ok', + '' + ]); })); test('success', function (t) { diff --git a/test/todo_explanation.js b/test/todo_explanation.js index a86f6b53..d0a57118 100644 --- a/test/todo_explanation.js +++ b/test/todo_explanation.js @@ -12,7 +12,7 @@ tap.test('tape todo test', { todo: process.versions.node.match(/0\.8\.\d+/) ? 'F assert.plan(1); test.createStream().pipe(concat(function (body) { - assert.equal( + assert.deepEqual( stripFullStack(body.toString('utf8')), [ 'TAP version 13', '# success', @@ -46,7 +46,7 @@ tap.test('tape todo test', { todo: process.versions.node.match(/0\.8\.\d+/) ? 'F '', '# ok', '' - ].join('\n') + ] ); })); diff --git a/test/todo_single.js b/test/todo_single.js index eeb7d265..090fbe38 100644 --- a/test/todo_single.js +++ b/test/todo_single.js @@ -12,24 +12,24 @@ tap.test('tape todo test', function (assert) { assert.plan(1); test.createStream().pipe(concat(function (body) { - assert.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# TODO failure\n' - + 'not ok 1 should be strictly equal # TODO\n' - + ' ---\n' - + ' operator: equal\n' - + ' expected: false\n' - + ' actual: true\n' - + ' at: Test. ($TEST/todo_single.js:$LINE:$COL)\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 1\n' - + '\n' - + '# ok\n' - ); + assert.deepEqual(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# TODO failure', + 'not ok 1 should be strictly equal # TODO', + ' ---', + ' operator: equal', + ' expected: false', + ' actual: true', + ' at: Test. ($TEST/todo_single.js:$LINE:$COL)', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 1', + '', + '# ok', + '' + ]); })); test('failure', { todo: true }, function (t) { diff --git a/test/too_many.js b/test/too_many.js index 3ff2d43b..aee90664 100644 --- a/test/too_many.js +++ b/test/too_many.js @@ -39,8 +39,9 @@ tap.test('array test', function (tt) { '1..6', '# tests 6', '# pass 5', - '# fail 1' - ].join('\n') + '\n'); + '# fail 1', + '' + ]); }; test.createStream().pipe(concat(tc)); diff --git a/test/undef.js b/test/undef.js index 3f935be0..204ac836 100644 --- a/test/undef.js +++ b/test/undef.js @@ -11,30 +11,30 @@ tap.test('array test', function (tt) { var test = tape.createHarness(); test.createStream().pipe(concat(function (body) { - tt.equal( - stripFullStack(body.toString('utf8')), - 'TAP version 13\n' - + '# undef\n' - + 'not ok 1 should be deeply equivalent\n' - + ' ---\n' - + ' operator: deepEqual\n' - + ' expected: |-\n' - + ' { beep: undefined }\n' - + ' actual: |-\n' - + ' {}\n' - + ' at: Test. ($TEST/undef.js:$LINE:$COL)\n' - + ' stack: |-\n' - + ' Error: should be deeply equivalent\n' - + ' [... stack stripped ...]\n' - + ' at Test. ($TEST/undef.js:$LINE:$COL)\n' - + ' [... stack stripped ...]\n' - + ' ...\n' - + '\n' - + '1..1\n' - + '# tests 1\n' - + '# pass 0\n' - + '# fail 1\n' - ); + tt.same(stripFullStack(body.toString('utf8')), [ + 'TAP version 13', + '# undef', + 'not ok 1 should be deeply equivalent', + ' ---', + ' operator: deepEqual', + ' expected: |-', + ' { beep: undefined }', + ' actual: |-', + ' {}', + ' at: Test. ($TEST/undef.js:$LINE:$COL)', + ' stack: |-', + ' Error: should be deeply equivalent', + ' [... stack stripped ...]', + ' at Test. ($TEST/undef.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + '' + ]); })); test('undef', function (t) {