From e6b6f119720e7e7b3aa43d72cdfa384f47e76cc2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 10 Jan 2020 00:39:14 -0800 Subject: [PATCH 1/7] [Refactor] remove unused code --- example/throw.js | 3 ++- index.js | 7 ------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/example/throw.js b/example/throw.js index 5fa8b94c..ef82c3ae 100644 --- a/example/throw.js +++ b/example/throw.js @@ -1,4 +1,5 @@ -var falafel = require('falafel'); +'use strict'; + var test = require('../'); test('throw', function (t) { diff --git a/index.js b/index.js index e326a96c..7ab29516 100644 --- a/index.js +++ b/index.js @@ -11,11 +11,6 @@ var canExit = typeof process !== 'undefined' && process && typeof process.exit === 'function' ; -var nextTick = typeof setImmediate !== 'undefined' - ? setImmediate - : process.nextTick -; - exports = module.exports = (function () { var harness; var lazyLoad = function () { @@ -100,8 +95,6 @@ exports.Test = Test; exports.test = exports; // tap compat exports.test.skip = Test.skip; -var exitInterval; - function createHarness(conf_) { if (!conf_) conf_ = {}; var results = createResult(); From 398503cfcabbaa56aa1e79d7523815a240d2d775 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 18 Jan 2020 15:01:16 -0800 Subject: [PATCH 2/7] [Deps] update `resolve` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cc9e2440..b92c62b1 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "is-regex": "~1.0.5", "minimist": "~1.2.0", "object-inspect": "~1.7.0", - "resolve": "~1.14.2", + "resolve": "~1.15.1", "resumer": "~0.0.0", "string.prototype.trim": "~1.2.1", "through": "~2.3.8" From 4526b39834db8061feeeb931dcf06047f29e9970 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 19 Feb 2020 16:24:57 -0800 Subject: [PATCH 3/7] [Tests] add tests for edge cases and numerics --- test/edge-cases.js | 237 +++++++++++++++++++++++++++++++++++++++++++++ test/numerics.js | 152 +++++++++++++++++++++++++++++ 2 files changed, 389 insertions(+) create mode 100644 test/edge-cases.js create mode 100644 test/numerics.js diff --git a/test/edge-cases.js b/test/edge-cases.js new file mode 100644 index 00000000..57c98d95 --- /dev/null +++ b/test/edge-cases.js @@ -0,0 +1,237 @@ +'use strict'; + +var tape = require('../'); +var tap = require('tap'); +var concat = require('concat-stream'); + +var stripFullStack = require('./common').stripFullStack; + +tap.test('edge cases', function (tt) { + tt.plan(1); + + var test = tape.createHarness(); + test.createStream().pipe(concat(function (body) { + tt.equal( + stripFullStack(body.toString('utf8')), + 'TAP version 13\n' + + '# zeroes\n' + + 'ok 1 0 equal to -0\n' + + 'ok 2 -0 equal to 0\n' + + 'not ok 3 0 notEqual to -0\n' + + ' ---\n' + + ' operator: notEqual\n' + + ' expected: |-\n' + + ' -0\n' + + ' actual: |-\n' + + ' 0\n' + + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' Error: 0 notEqual to -0\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'not ok 4 -0 notEqual to 0\n' + + ' ---\n' + + ' operator: notEqual\n' + + ' expected: |-\n' + + ' 0\n' + + ' actual: |-\n' + + ' -0\n' + + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' Error: -0 notEqual to 0\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'ok 5 0 strictEqual to -0\n' + + 'ok 6 -0 strictEqual to 0\n' + + 'not ok 7 0 notStrictEqual to -0\n' + + ' ---\n' + + ' operator: notEqual\n' + + ' expected: |-\n' + + ' -0\n' + + ' actual: |-\n' + + ' 0\n' + + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' Error: 0 notStrictEqual to -0\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'not ok 8 -0 notStrictEqual to 0\n' + + ' ---\n' + + ' operator: notEqual\n' + + ' expected: |-\n' + + ' 0\n' + + ' actual: |-\n' + + ' -0\n' + + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' Error: -0 notStrictEqual to 0\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'ok 9 0 deepLooseEqual to -0\n' + + 'ok 10 -0 deepLooseEqual to 0\n' + + 'not ok 11 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 12 -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 13 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 14 -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 15 0 notDeepEqual to -0\n' + + 'ok 16 -0 notDeepEqual to 0\n' + + '# NaNs\n' + + 'not ok 17 NaN equal to NaN\n' + + ' ---\n' + + ' operator: equal\n' + + ' expected: NaN\n' + + ' actual: NaN\n' + + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' Error: NaN equal to NaN\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'ok 18 NaN notEqual to NaN\n' + + 'not ok 19 NaN strictEqual to NaN\n' + + ' ---\n' + + ' operator: equal\n' + + ' expected: NaN\n' + + ' actual: NaN\n' + + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' Error: NaN strictEqual to NaN\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'ok 20 NaN notStrictEqual to NaN\n' + + 'not ok 21 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 22 NaN notDeepLooseEqual to NaN\n' + + 'ok 23 NaN deepEqual to NaN\n' + + 'not ok 24 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..24\n' + + '# tests 24\n' + + '# pass 12\n' + + '# fail 12\n' + ); + })); + + test('zeroes', function (t) { + t.equal(0, -0, '0 equal to -0'); + t.equal(-0, 0, '-0 equal to 0'); + t.notEqual(0, -0, '0 notEqual to -0'); + t.notEqual(-0, 0, '-0 notEqual to 0'); + + t.strictEqual(0, -0, '0 strictEqual to -0'); + t.strictEqual(-0, 0, '-0 strictEqual to 0'); + t.notStrictEqual(0, -0, '0 notStrictEqual to -0'); + t.notStrictEqual(-0, 0, '-0 notStrictEqual to 0'); + + t.deepLooseEqual(0, -0, '0 deepLooseEqual to -0'); + t.deepLooseEqual(-0, 0, '-0 deepLooseEqual to 0'); + t.notDeepLooseEqual(0, -0, '0 notDeepLooseEqual to -0'); + t.notDeepLooseEqual(-0, 0, '-0 notDeepLooseEqual to 0'); + + t.deepEqual(0, -0, '0 deepEqual to -0'); + t.deepEqual(-0, 0, '-0 deepEqual to 0'); + t.notDeepEqual(0, -0, '0 notDeepEqual to -0'); + t.notDeepEqual(-0, 0, '-0 notDeepEqual to 0'); + + t.end(); + }); + + test('NaNs', function (t) { + t.equal(NaN, NaN, 'NaN equal to NaN'); + t.notEqual(NaN, NaN, 'NaN notEqual to NaN'); + + t.strictEqual(NaN, NaN, 'NaN strictEqual to NaN'); + t.notStrictEqual(NaN, NaN, 'NaN notStrictEqual to NaN'); + + t.deepLooseEqual(NaN, NaN, 'NaN deepLooseEqual to NaN'); + t.notDeepLooseEqual(NaN, NaN, 'NaN notDeepLooseEqual to NaN'); + + t.deepEqual(NaN, NaN, 'NaN deepEqual to NaN'); + t.notDeepEqual(NaN, NaN, 'NaN notDeepEqual to NaN'); + + t.end(); + }); +}); diff --git a/test/numerics.js b/test/numerics.js new file mode 100644 index 00000000..5e080316 --- /dev/null +++ b/test/numerics.js @@ -0,0 +1,152 @@ +'use strict'; + +var tape = require('../'); +var tap = require('tap'); +var concat = require('concat-stream'); + +var stripFullStack = require('./common').stripFullStack; + +tap.test('numerics', function (tt) { + tt.plan(1); + + 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' + + 'not ok 5 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 6 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 7 number notStrictEqual to string\n' + + 'ok 8 string notStrictEqual to number\n' + + 'ok 9 number deepLooseEqual to string\n' + + 'ok 10 string deepLooseEqual to number\n' + + 'not ok 11 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 12 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 13 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 14 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 15 number notDeepEqual to string\n' + + 'ok 16 string notDeepEqual to number\n' + + '\n1..16\n' + + '# tests 16\n' + + '# pass 8\n' + + '# fail 8\n' + ); + })); + + test('numeric strings', function (t) { + t.equal(3, '3', 'number equal to string'); + t.equal('3', 3, 'string equal to number'); + t.notEqual(3, '3', 'number notEqual to string'); + t.notEqual('3', 3, 'string notEqual to number'); + + t.strictEqual(3, '3', 'number strictEqual to string'); + t.strictEqual('3', 3, 'string strictEqual to number'); + t.notStrictEqual(3, '3', 'number notStrictEqual to string'); + t.notStrictEqual('3', 3, 'string notStrictEqual to number'); + + t.deepLooseEqual(3, '3', 'number deepLooseEqual to string'); + t.deepLooseEqual('3', 3, 'string deepLooseEqual to number'); + t.notDeepLooseEqual(3, '3', 'number notDeepLooseEqual to string'); + t.notDeepLooseEqual('3', 3, 'string notDeepLooseEqual to number'); + + t.deepEqual(3, '3', 'number deepEqual to string'); + t.deepEqual('3', 3, 'string deepEqual to number'); + t.notDeepEqual(3, '3', 'number notDeepEqual to string'); + t.notDeepEqual('3', 3, 'string notDeepEqual to number'); + + t.end(); + }); +}); From d686aa2542a3641255a5427408cf4173450b9d6e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 25 Feb 2020 15:33:29 -0800 Subject: [PATCH 4/7] [eslint] enable `quotes` rule --- .eslintrc | 3 +++ test/circular-things.js | 2 +- test/comment.js | 2 +- test/create_multiple_streams.js | 2 +- test/deep-equal-failure.js | 6 +++--- test/end-as-callback.js | 28 ++++++++++++++-------------- test/not-deep-equal-failure.js | 6 +++--- test/not-equal-failure.js | 2 +- test/onFailure.js | 10 +++++----- test/onFinish.js | 6 +++--- test/only-twice.js | 2 +- test/only.js | 8 ++++---- test/stackTrace.js | 6 +++--- test/throws.js | 16 ++++++++-------- 14 files changed, 51 insertions(+), 48 deletions(-) diff --git a/.eslintrc b/.eslintrc index 674234d4..40369d2a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,6 +3,9 @@ "rules": { "indent": ["error", 4], "key-spacing": "error", + "quotes": ["error", "single", { + "avoidEscape": true, + }], "semi": ["error", "always"], "space-before-function-paren": ["error", { "anonymous": "always", diff --git a/test/circular-things.js b/test/circular-things.js index 98e57a38..dcab2b12 100644 --- a/test/circular-things.js +++ b/test/circular-things.js @@ -35,7 +35,7 @@ tap.test('circular test', function (assert) { ); })); - test("circular", function (t) { + test('circular', function (t) { t.plan(1); var circular = {}; circular.circular = circular; diff --git a/test/comment.js b/test/comment.js index b3f9bcc3..007d457a 100644 --- a/test/comment.js +++ b/test/comment.js @@ -130,7 +130,7 @@ tap.test('non-string types', function (assert) { t.comment(42); t.comment(6.66); t.comment({}); - t.comment({"answer": 42}); + t.comment({'answer': 42}); function ConstructorFunction() {} t.comment(new ConstructorFunction()); t.comment(ConstructorFunction); diff --git a/test/create_multiple_streams.js b/test/create_multiple_streams.js index 53f43091..8ecac498 100644 --- a/test/create_multiple_streams.js +++ b/test/create_multiple_streams.js @@ -23,7 +23,7 @@ tape.test('createMultipleStreams', function (tt) { }); th.onFinish(function () { - tt.equal(th._results.count, 2, "harness test ran"); + tt.equal(th._results.count, 2, 'harness test ran'); tt.equal(th._results.fail, 0, "harness test didn't fail"); }); }); diff --git a/test/deep-equal-failure.js b/test/deep-equal-failure.js index 6bf91d8d..e1f2659e 100644 --- a/test/deep-equal-failure.js +++ b/test/deep-equal-failure.js @@ -62,7 +62,7 @@ tap.test('deep equal failure', function (assert) { }); }); - test("deep equal", function (t) { + test('deep equal', function (t) { t.plan(1); t.equal({a: 1}, {b: 2}); }); @@ -123,7 +123,7 @@ tap.test('deep equal failure, depth 6, with option', function (assert) { }); }); - test("deep equal", {objectPrintDepth: 6}, function (t) { + test('deep equal', {objectPrintDepth: 6}, function (t) { t.plan(1); t.equal({ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }, { a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }); }); @@ -184,7 +184,7 @@ tap.test('deep equal failure, depth 6, without option', function (assert) { }); }); - test("deep equal", function (t) { + test('deep equal', function (t) { t.plan(1); t.equal({ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }, { a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }); }); diff --git a/test/end-as-callback.js b/test/end-as-callback.js index a9786881..a8c70940 100644 --- a/test/end-as-callback.js +++ b/test/end-as-callback.js @@ -1,9 +1,9 @@ -var tap = require("tap"); -var forEach = require("for-each"); -var tape = require("../"); +var tap = require('tap'); +var forEach = require('for-each'); +var tape = require('../'); var concat = require('concat-stream'); -tap.test("tape assert.end as callback", function (tt) { +tap.test('tape assert.end as callback', function (tt) { var test = tape.createHarness({ exit: false }); test.createStream().pipe(concat(function (rows) { @@ -26,27 +26,27 @@ tap.test("tape assert.end as callback", function (tt) { tt.end(); })); - test("do a task and write", function (assert) { - fakeAsyncTask("foo", function (err, value) { + test('do a task and write', function (assert) { + fakeAsyncTask('foo', function (err, value) { assert.ifError(err); - assert.equal(value, "taskfoo"); + assert.equal(value, 'taskfoo'); - fakeAsyncWrite("bar", assert.end); + fakeAsyncWrite('bar', assert.end); }); }); - test("do a task and write fail", function (assert) { - fakeAsyncTask("bar", function (err, value) { + test('do a task and write fail', function (assert) { + fakeAsyncTask('bar', function (err, value) { assert.ifError(err); - assert.equal(value, "taskbar"); + assert.equal(value, 'taskbar'); - fakeAsyncWriteFail("baz", assert.end); + fakeAsyncWriteFail('baz', assert.end); }); }); }); function fakeAsyncTask(name, cb) { - cb(null, "task" + name); + cb(null, 'task' + name); } function fakeAsyncWrite(name, cb) { @@ -54,7 +54,7 @@ function fakeAsyncWrite(name, cb) { } function fakeAsyncWriteFail(name, cb) { - cb(new Error("fail")); + cb(new Error('fail')); } /** diff --git a/test/not-deep-equal-failure.js b/test/not-deep-equal-failure.js index 166f7e02..63fbd614 100644 --- a/test/not-deep-equal-failure.js +++ b/test/not-deep-equal-failure.js @@ -62,7 +62,7 @@ tap.test('deep equal failure', function (assert) { }); }); - test("not deep equal", function (t) { + test('not deep equal', function (t) { t.plan(1); t.notDeepEqual({b: 2}, {b: 2}); }); @@ -123,7 +123,7 @@ tap.test('not deep equal failure, depth 6, with option', function (assert) { }); }); - test("not deep equal", {objectPrintDepth: 6}, function (t) { + test('not deep equal', {objectPrintDepth: 6}, function (t) { t.plan(1); t.notDeepEqual({ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }, { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }); }); @@ -184,7 +184,7 @@ tap.test('not deep equal failure, depth 6, without option', function (assert) { }); }); - test("not deep equal", function (t) { + test('not deep equal', function (t) { t.plan(1); t.notDeepEqual({ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }, { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }); }); diff --git a/test/not-equal-failure.js b/test/not-equal-failure.js index 83fc0a4e..28e31a65 100644 --- a/test/not-equal-failure.js +++ b/test/not-equal-failure.js @@ -60,7 +60,7 @@ tap.test('not equal failure', function (assert) { }); }); - test("not equal", function (t) { + test('not equal', function (t) { t.plan(1); t.notEqual(2, 2); }); diff --git a/test/onFailure.js b/test/onFailure.js index ec5d9345..666227d7 100644 --- a/test/onFailure.js +++ b/test/onFailure.js @@ -1,5 +1,5 @@ -var tap = require("tap"); -var tape = require("../").createHarness(); +var tap = require('tap'); +var tape = require('../').createHarness(); //Because this test passing depends on a failure, //we must direct the failing output of the inner test @@ -7,15 +7,15 @@ var noop = function () {}; var mockSink = {on: noop, removeListener: noop, emit: noop, end: noop}; tape.createStream().pipe(mockSink); -tap.test("on failure", { timeout: 1000 }, function (tt) { +tap.test('on failure', { timeout: 1000 }, function (tt) { tt.plan(1); - tape("dummy test", function (t) { + tape('dummy test', function (t) { t.fail(); t.end(); }); tape.onFailure(function () { - tt.pass("tape ended"); + tt.pass('tape ended'); }); }); diff --git a/test/onFinish.js b/test/onFinish.js index 80ccf051..7881273e 100644 --- a/test/onFinish.js +++ b/test/onFinish.js @@ -1,7 +1,7 @@ -var tap = require("tap"); -var tape = require("../"); +var tap = require('tap'); +var tape = require('../'); -tap.test("on finish", {timeout: 1000}, function (tt) { +tap.test('on finish', {timeout: 1000}, function (tt) { tt.plan(1); tape.onFinish(function () { tt.pass('tape ended'); diff --git a/test/only-twice.js b/test/only-twice.js index 47c97f5f..cca7c758 100644 --- a/test/only-twice.js +++ b/test/only-twice.js @@ -4,7 +4,7 @@ var tap = require('tap'); tap.test('only twice error', function (assert) { var test = tape.createHarness({ exit: false }); - test.only("first only", function (t) { + test.only('first only', function (t) { t.end(); }); diff --git a/test/only.js b/test/only.js index bcfc9058..41f2f839 100644 --- a/test/only.js +++ b/test/only.js @@ -25,21 +25,21 @@ tap.test('tape only test', function (tt) { test.createStream().pipe(concat(tc)); - test("never run fail", function (t) { + test('never run fail', function (t) { ran.push(1); t.equal(true, false); t.end(); }); - test("never run success", function (t) { + test('never run success', function (t) { ran.push(2); t.equal(true, true); t.end(); }); - test.only("run success", function (t) { + test.only('run success', function (t) { ran.push(3); - t.ok(true, "assert name"); + t.ok(true, 'assert name'); t.end(); }); }); diff --git a/test/stackTrace.js b/test/stackTrace.js index e7f8d4b7..54298184 100644 --- a/test/stackTrace.js +++ b/test/stackTrace.js @@ -17,7 +17,7 @@ tap.test('preserves stack trace with newlines', function (tt) { tt.deepEqual(data, { ok: false, id: 1, - name: "Error: Preserve stack", + name: 'Error: Preserve stack', diag: { stack: stackTrace, operator: 'error', @@ -121,7 +121,7 @@ tap.test('preserves stack trace for failed assertions', function (tt) { tt.deepEqual(data, { ok: false, id: 1, - name: "true should be false", + name: 'true should be false', diag: { at: at, stack: stack, @@ -186,7 +186,7 @@ tap.test('preserves stack trace for failed assertions where actual===falsy', fun tt.deepEqual(data, { ok: false, id: 1, - name: "false should be true", + name: 'false should be true', diag: { at: at, stack: stack, diff --git a/test/throws.js b/test/throws.js index a919b4ec..1628d822 100644 --- a/test/throws.js +++ b/test/throws.js @@ -39,7 +39,7 @@ tap.test('failures', function (tt) { + ' expected: |-\n' + ' undefined\n' + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage() + "] message: '" + getNonFunctionMessage() + "' }\n" + + ' { [TypeError: ' + getNonFunctionMessage() + "] message: '" + getNonFunctionMessage() + "' }\n" + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + ' stack: |-\n' + ' TypeError: ' + getNonFunctionMessage(undefined) + '\n' @@ -53,7 +53,7 @@ tap.test('failures', function (tt) { + ' expected: |-\n' + ' undefined\n' + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage(null) + "] message: '" + getNonFunctionMessage(null) + "' }\n" + + ' { [TypeError: ' + getNonFunctionMessage(null) + "] message: '" + getNonFunctionMessage(null) + "' }\n" + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + ' stack: |-\n' + ' TypeError: ' + getNonFunctionMessage(null) + '\n' @@ -67,7 +67,7 @@ tap.test('failures', function (tt) { + ' expected: |-\n' + ' undefined\n' + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage(true) + "] message: '" + getNonFunctionMessage(true) + "' }\n" + + ' { [TypeError: ' + getNonFunctionMessage(true) + "] message: '" + getNonFunctionMessage(true) + "' }\n" + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + ' stack: |-\n' + ' TypeError: ' + getNonFunctionMessage(true) + '\n' @@ -81,7 +81,7 @@ tap.test('failures', function (tt) { + ' expected: |-\n' + ' undefined\n' + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage(false) + "] message: '" + getNonFunctionMessage(false) + "' }\n" + + ' { [TypeError: ' + getNonFunctionMessage(false) + "] message: '" + getNonFunctionMessage(false) + "' }\n" + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + ' stack: |-\n' + ' TypeError: ' + getNonFunctionMessage(false) + '\n' @@ -95,7 +95,7 @@ tap.test('failures', function (tt) { + ' expected: |-\n' + ' undefined\n' + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage('abc') + "] message: '" + getNonFunctionMessage('abc') + "' }\n" + + ' { [TypeError: ' + getNonFunctionMessage('abc') + "] message: '" + getNonFunctionMessage('abc') + "' }\n" + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + ' stack: |-\n' + ' TypeError: ' + getNonFunctionMessage('abc') + '\n' @@ -109,7 +109,7 @@ tap.test('failures', function (tt) { + ' expected: |-\n' + ' undefined\n' + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage(/a/g) + "] message: '" + getNonFunctionMessage(/a/g) + "' }\n" + + ' { [TypeError: ' + getNonFunctionMessage(/a/g) + "] message: '" + getNonFunctionMessage(/a/g) + "' }\n" + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + ' stack: |-\n' + ' TypeError: ' + getNonFunctionMessage(/a/g) + '\n' @@ -123,7 +123,7 @@ tap.test('failures', function (tt) { + ' expected: |-\n' + ' undefined\n' + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage([]) + "] message: '" + getNonFunctionMessage([]) + "' }\n" + + ' { [TypeError: ' + getNonFunctionMessage([]) + "] message: '" + getNonFunctionMessage([]) + "' }\n" + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + ' stack: |-\n' + ' TypeError: ' + getNonFunctionMessage([]) + '\n' @@ -137,7 +137,7 @@ tap.test('failures', function (tt) { + ' expected: |-\n' + ' undefined\n' + ' actual: |-\n' - + " { [TypeError: " + getNonFunctionMessage({}) + "] message: '" + getNonFunctionMessage({}) + "' }\n" + + ' { [TypeError: ' + getNonFunctionMessage({}) + "] message: '" + getNonFunctionMessage({}) + "' }\n" + ' at: Test. ($TEST/throws.js:$LINE:$COL)\n' + ' stack: |-\n' + ' TypeError: ' + getNonFunctionMessage({}) + '\n' From 98b2695ceebf6e1e175d29f291c9c1073416d947 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 25 Feb 2020 15:40:34 -0800 Subject: [PATCH 5/7] [Tests] sync new test cases from master --- test/default-messages.js | 33 ++++++++++--- test/edge-cases.js | 99 +++++++++++++++++++++++++++++---------- test/messages/defaults.js | 15 +++++- test/numerics.js | 63 ++++++++++++++++++------- 4 files changed, 162 insertions(+), 48 deletions(-) diff --git a/test/default-messages.js b/test/default-messages.js index dcfdbffc..5651a8ec 100644 --- a/test/default-messages.js +++ b/test/default-messages.js @@ -1,8 +1,12 @@ +'use strict'; + var tap = require('tap'); var path = require('path'); var spawn = require('child_process').spawn; var concat = require('concat-stream'); +var stripFullStack = require('./common').stripFullStack; + tap.test('default messages', function (t) { t.plan(1); @@ -10,7 +14,7 @@ tap.test('default messages', function (t) { ps.stdout.pipe(concat(function (rows) { - t.same(rows.toString('utf8'), [ + t.same(stripFullStack(rows.toString('utf8')), [ 'TAP version 13', '# default messages', 'ok 1 should be truthy', @@ -19,13 +23,28 @@ tap.test('default messages', function (t) { 'ok 4 should not be equal', 'ok 5 should be equivalent', 'ok 6 should be equivalent', - 'ok 7 should be equivalent', - '', - '1..7', - '# tests 7', - '# pass 7', + 'ok 7 should be equal', + 'ok 8 should not be equal', + 'ok 9 should be equivalent', + 'not ok 10 should not be equivalent', + ' ---', + ' operator: notDeepEqual', + ' expected: true', + ' actual: true', + ' at: Test. ($TEST/messages/defaults.js:$LINE:$COL)', + ' stack: |-', + ' Error: should not be equivalent', + ' [... stack stripped ...]', + ' at Test. ($TEST/messages/defaults.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 11 should be equivalent', + 'ok 12 should be equivalent', '', - '# ok' + '1..12', + '# tests 12', + '# pass 11', + '# fail 1' ].join('\n') + '\n\n'); })); }); diff --git a/test/edge-cases.js b/test/edge-cases.js index 57c98d95..96da8548 100644 --- a/test/edge-cases.js +++ b/test/edge-cases.js @@ -45,9 +45,39 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'ok 5 0 strictEqual to -0\n' - + 'ok 6 -0 strictEqual to 0\n' - + 'not ok 7 0 notStrictEqual 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: notDeepLooseEqual\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: notDeepLooseEqual\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' + + 'ok 9 0 strictEqual to -0\n' + + 'ok 10 -0 strictEqual to 0\n' + + 'not ok 11 0 notStrictEqual to -0\n' + ' ---\n' + ' operator: notEqual\n' + ' expected: |-\n' @@ -61,7 +91,7 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 8 -0 notStrictEqual to 0\n' + + 'not ok 12 -0 notStrictEqual to 0\n' + ' ---\n' + ' operator: notEqual\n' + ' expected: |-\n' @@ -75,9 +105,9 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'ok 9 0 deepLooseEqual to -0\n' - + 'ok 10 -0 deepLooseEqual to 0\n' - + 'not ok 11 0 notDeepLooseEqual 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' @@ -91,7 +121,7 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 12 -0 notDeepLooseEqual to 0\n' + + 'not ok 16 -0 notDeepLooseEqual to 0\n' + ' ---\n' + ' operator: notDeepLooseEqual\n' + ' expected: |-\n' @@ -105,7 +135,7 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 13 0 deepEqual to -0\n' + + 'not ok 17 0 deepEqual to -0\n' + ' ---\n' + ' operator: deepEqual\n' + ' expected: |-\n' @@ -119,7 +149,7 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 14 -0 deepEqual to 0\n' + + 'not ok 18 -0 deepEqual to 0\n' + ' ---\n' + ' operator: deepEqual\n' + ' expected: |-\n' @@ -133,10 +163,10 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'ok 15 0 notDeepEqual to -0\n' - + 'ok 16 -0 notDeepEqual to 0\n' + + 'ok 19 0 notDeepEqual to -0\n' + + 'ok 20 -0 notDeepEqual to 0\n' + '# NaNs\n' - + 'not ok 17 NaN equal to NaN\n' + + 'not ok 21 NaN equal to NaN\n' + ' ---\n' + ' operator: equal\n' + ' expected: NaN\n' @@ -148,8 +178,21 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'ok 18 NaN notEqual to NaN\n' - + 'not ok 19 NaN strictEqual to NaN\n' + + 'ok 22 NaN notEqual to NaN\n' + + 'not ok 23 NaN looseEqual 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 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' + + 'not ok 25 NaN strictEqual to NaN\n' + ' ---\n' + ' operator: equal\n' + ' expected: NaN\n' @@ -161,8 +204,8 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'ok 20 NaN notStrictEqual to NaN\n' - + 'not ok 21 NaN deepLooseEqual to NaN\n' + + 'ok 26 NaN notStrictEqual to NaN\n' + + 'not ok 27 NaN deepLooseEqual to NaN\n' + ' ---\n' + ' operator: deepLooseEqual\n' + ' expected: NaN\n' @@ -174,9 +217,9 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'ok 22 NaN notDeepLooseEqual to NaN\n' - + 'ok 23 NaN deepEqual to NaN\n' - + 'not ok 24 NaN notDeepEqual to NaN\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' @@ -188,10 +231,10 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + '\n1..24\n' - + '# tests 24\n' - + '# pass 12\n' - + '# fail 12\n' + + '\n1..30\n' + + '# tests 30\n' + + '# pass 15\n' + + '# fail 15\n' ); })); @@ -201,6 +244,11 @@ tap.test('edge cases', function (tt) { t.notEqual(0, -0, '0 notEqual to -0'); t.notEqual(-0, 0, '-0 notEqual to 0'); + t.looseEqual(0, -0, '0 looseEqual to -0'); + t.looseEqual(-0, 0, '-0 looseEqual to 0'); + t.notLooseEqual(0, -0, '0 notLooseEqual to -0'); + t.notLooseEqual(-0, 0, '-0 notLooseEqual to 0'); + t.strictEqual(0, -0, '0 strictEqual to -0'); t.strictEqual(-0, 0, '-0 strictEqual to 0'); t.notStrictEqual(0, -0, '0 notStrictEqual to -0'); @@ -223,6 +271,9 @@ tap.test('edge cases', function (tt) { t.equal(NaN, NaN, 'NaN equal to NaN'); t.notEqual(NaN, NaN, 'NaN notEqual to NaN'); + t.looseEqual(NaN, NaN, 'NaN looseEqual to NaN'); + t.notLooseEqual(NaN, NaN, 'NaN notLooseEqual to NaN'); + t.strictEqual(NaN, NaN, 'NaN strictEqual to NaN'); t.notStrictEqual(NaN, NaN, 'NaN notStrictEqual to NaN'); diff --git a/test/messages/defaults.js b/test/messages/defaults.js index 836a34aa..e9672147 100644 --- a/test/messages/defaults.js +++ b/test/messages/defaults.js @@ -1,12 +1,25 @@ +'use strict'; + var test = require('../../'); test('default messages', function (t) { - t.plan(7); + t.plan(12); + t.ok(true); t.notOk(false); + t.equal(true, true); t.notEqual(true, false); + + t.looseEqual(true, true); + t.notLooseEqual(true, false); + + t.strictEqual(true, true); + t.notStrictEqual(true, false); + t.deepEqual(true, true); + t.notDeepEqual(true, true); + t.deepLooseEqual(true, true); t.notDeepLooseEqual(true, false); }); diff --git a/test/numerics.js b/test/numerics.js index 5e080316..a425de4d 100644 --- a/test/numerics.js +++ b/test/numerics.js @@ -41,7 +41,33 @@ tap.test('numerics', function (tt) { + ' ...\n' + 'ok 3 number notEqual to string\n' + 'ok 4 string notEqual to number\n' - + 'not ok 5 number strictEqual to string\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: notDeepLooseEqual\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: notDeepLooseEqual\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' @@ -53,7 +79,7 @@ tap.test('numerics', function (tt) { + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 6 string strictEqual to number\n' + + 'not ok 10 string strictEqual to number\n' + ' ---\n' + ' operator: equal\n' + ' expected: 3\n' @@ -65,11 +91,11 @@ tap.test('numerics', function (tt) { + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'ok 7 number notStrictEqual to string\n' - + 'ok 8 string notStrictEqual to number\n' - + 'ok 9 number deepLooseEqual to string\n' - + 'ok 10 string deepLooseEqual to number\n' - + 'not ok 11 number notDeepLooseEqual to string\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' @@ -81,7 +107,7 @@ tap.test('numerics', function (tt) { + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 12 string notDeepLooseEqual to number\n' + + 'not ok 16 string notDeepLooseEqual to number\n' + ' ---\n' + ' operator: notDeepLooseEqual\n' + ' expected: 3\n' @@ -93,7 +119,7 @@ tap.test('numerics', function (tt) { + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 13 number deepEqual to string\n' + + 'not ok 17 number deepEqual to string\n' + ' ---\n' + ' operator: deepEqual\n' + ' expected: \'3\'\n' @@ -105,7 +131,7 @@ tap.test('numerics', function (tt) { + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 14 string deepEqual to number\n' + + 'not ok 18 string deepEqual to number\n' + ' ---\n' + ' operator: deepEqual\n' + ' expected: 3\n' @@ -117,12 +143,12 @@ tap.test('numerics', function (tt) { + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'ok 15 number notDeepEqual to string\n' - + 'ok 16 string notDeepEqual to number\n' - + '\n1..16\n' - + '# tests 16\n' - + '# pass 8\n' - + '# fail 8\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' ); })); @@ -132,6 +158,11 @@ tap.test('numerics', function (tt) { t.notEqual(3, '3', 'number notEqual to string'); t.notEqual('3', 3, 'string notEqual to number'); + t.looseEqual(3, '3', 'number looseEqual to string'); + t.looseEqual('3', 3, 'string looseEqual to number'); + t.notLooseEqual(3, '3', 'number notLooseEqual to string'); + t.notLooseEqual('3', 3, 'string notLooseEqual to number'); + t.strictEqual(3, '3', 'number strictEqual to string'); t.strictEqual('3', 3, 'string strictEqual to number'); t.notStrictEqual(3, '3', 'number notStrictEqual to string'); From c4119c2274dbfa13b248b0ae00adf7b3dc827cbb Mon Sep 17 00:00:00 2001 From: Raynos Date: Mon, 2 Mar 2020 14:36:27 +0100 Subject: [PATCH 6/7] [patch] Print name of test that didnt end (#498) A stack trace should be actionable. --- lib/test.js | 2 +- test/exit.js | 33 +++++++++++++++++++++++++++++++++ test/exit/missing_end.js | 12 ++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 test/exit/missing_end.js diff --git a/lib/test.js b/lib/test.js index 1be9494f..f4353897 100644 --- a/lib/test.js +++ b/lib/test.js @@ -188,7 +188,7 @@ Test.prototype._exit = function () { exiting: true }); } else if (!this.ended) { - this.fail('test exited without ending', { + this.fail('test exited without ending: ' + this.name, { exiting: true }); } diff --git a/test/exit.js b/test/exit.js index fba56b23..686c3da9 100644 --- a/test/exit.js +++ b/test/exit.js @@ -202,3 +202,36 @@ tap.test('todo failing', function (t) { t.equal(code, 0); }); }); + +tap.test('forgot to call t.end()', function (t) { + t.plan(2); + + var tc = function (rows) { + t.same(stripFullStack(rows.toString('utf8')), [ + 'TAP version 13', + '# first', + 'ok 1 should be truthy', + '# oops forgot end', + 'ok 2 should be truthy', + 'not ok 3 test exited without ending: oops forgot end', + ' ---', + ' operator: fail', + ' at: process. ($TAPE/index.js:$LINE:$COL)', + ' stack: |-', + ' Error: test exited without ending: oops forgot end', + ' [... stack stripped ...]', + ' ...', + '', + '1..3', + '# tests 3', + '# pass 2', + '# fail 1' + ].join('\n') + '\n\n'); + }; + + var ps = spawn(process.execPath, [path.join(__dirname, '/exit/missing_end.js')]); + ps.stdout.pipe(concat(tc)); + ps.on('exit', function (code) { + t.notEqual(code, 0); + }); +}); diff --git a/test/exit/missing_end.js b/test/exit/missing_end.js new file mode 100644 index 00000000..7616fec1 --- /dev/null +++ b/test/exit/missing_end.js @@ -0,0 +1,12 @@ +'use strict'; + +var test = require('../../'); + +test('first', function (t) { + t.ok(true); + t.end(); +}); + +test('oops forgot end', function (t) { + t.ok(true); +}); From 2914a7b28fab0b1e9e52fcfbba49baed5f41762f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 2 Mar 2020 12:09:23 -0800 Subject: [PATCH 7/7] v4.13.2 - [patch] Print name of test that didnt end (#498) - [Refactor] remove unused code - [Deps] update `resolve` - [eslint] enable `quotes` rule - [Tests] add tests for edge cases and numerics --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b92c62b1..eff18237 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tape", - "version": "4.13.1", + "version": "4.13.2", "description": "tap-producing test harness for node and browsers", "main": "index.js", "bin": "./bin/tape",