From 93d6cd7d28578e8f50284e406daa643f48a00d61 Mon Sep 17 00:00:00 2001 From: Tim Gates Date: Fri, 3 Apr 2020 21:48:57 +1100 Subject: [PATCH 01/10] [Tests] Fix simple typo, placehodler -> placeholder (#500) There is a small typo in test/common.js. Should read `placeholder` rather than `placehodler`. --- test/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/common.js b/test/common.js index ae1681e8..e7df7d1c 100644 --- a/test/common.js +++ b/test/common.js @@ -21,7 +21,7 @@ module.exports.getDiag = function (body) { // 1) The base checkout directory of tape might change. Because stack traces // include absolute paths, the stack traces will change depending on the // checkout path. We handle this by replacing the base test directory with a -// placeholder $TEST variable and the package root with a placehodler +// placeholder $TEST variable and the package root with a placeholder // $TAPE variable. // 2) Line positions within the file might change. We handle this by replacing // line and column markers with placeholder $LINE and $COL "variables" From 6326dc62e761b92b87377b30c539f762ed2e9052 Mon Sep 17 00:00:00 2001 From: Sceat <11330271+Sceat@users.noreply.github.com> Date: Fri, 3 Apr 2020 16:04:52 +0200 Subject: [PATCH 02/10] [Docs] add an optional emoji version for tap-spec consumer (#501) --- readme.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.markdown b/readme.markdown index 6854811f..28a66a73 100644 --- a/readme.markdown +++ b/readme.markdown @@ -117,6 +117,7 @@ that will output something pretty if you pipe TAP into them: - [tap-react-browser](https://github.com/mcnuttandrew/tap-react-browser) - [tap-junit](https://github.com/dhershman1/tap-junit) - [tap-nyc](https://github.com/MegaArman/tap-nyc) +- [tap-spec (emoji patch)](https://github.com/Sceat/tap-spec-emoji) To use them, try `node test/index.js | tap-spec` or pipe it into one of the modules of your choice! From bc1334bc008e5d5aecd61c580aad1657932da146 Mon Sep 17 00:00:00 2001 From: David Anson Date: Mon, 24 Feb 2020 21:22:06 -0800 Subject: [PATCH 03/10] [readme] Add link to tape-player (in-process reporter) (#496) --- readme.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.markdown b/readme.markdown index 28a66a73..ff187229 100644 --- a/readme.markdown +++ b/readme.markdown @@ -134,6 +134,7 @@ By default, uncaught exceptions in your tests will not be intercepted, and will - Different test syntax with https://github.com/pguth/flip-tape (warning: mutates String.prototype) - Electron test runner with https://github.com/tundrax/electron-tap - Concurrency support with https://github.com/imsnif/mixed-tape +- In-process reporting with https://github.com/DavidAnson/tape-player # methods From 9b876753153e0a8f94894fbbe9e08d78df12b039 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 24 Apr 2020 14:29:30 -0700 Subject: [PATCH 04/10] [examples] add `ecstatic` --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index eff18237..c3f14bbb 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "devDependencies": { "concat-stream": "^1.6.2", "eclint": "^2.8.1", + "ecstatic": "^4.1.4", "eslint": "^6.8.0", "falafel": "^2.1.0", "js-yaml": "^3.13.1", From 33712e2dd7a89c6c97f58bfe38882631616363c4 Mon Sep 17 00:00:00 2001 From: Ron Gruesbeck Date: Fri, 1 May 2020 07:54:24 -0700 Subject: [PATCH 05/10] [readme] add `tape-repeater` (#511) --- readme.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.markdown b/readme.markdown index ff187229..4676bce8 100644 --- a/readme.markdown +++ b/readme.markdown @@ -118,6 +118,7 @@ that will output something pretty if you pipe TAP into them: - [tap-junit](https://github.com/dhershman1/tap-junit) - [tap-nyc](https://github.com/MegaArman/tap-nyc) - [tap-spec (emoji patch)](https://github.com/Sceat/tap-spec-emoji) +- [tape-repeater](https://github.com/rgruesbeck/tape-repeater) To use them, try `node test/index.js | tap-spec` or pipe it into one of the modules of your choice! From 751e592623c17bf272f0931b83dd0d53c679872d Mon Sep 17 00:00:00 2001 From: David Anson Date: Mon, 18 May 2020 21:21:37 -0700 Subject: [PATCH 06/10] [Fix] Update RegExp for matching stack frames to handle Promise/then scenario (#516) Fixes #515 --- lib/test.js | 8 +++--- test/anonymous-fn.js | 2 +- test/exit.js | 2 +- test/fail.js | 2 +- test/stackTrace.js | 68 +++++++++++++++++++++++++++++++++++++++++--- test/too_many.js | 2 +- 6 files changed, 72 insertions(+), 12 deletions(-) diff --git a/lib/test.js b/lib/test.js index f4353897..3e75ee2f 100644 --- a/lib/test.js +++ b/lib/test.js @@ -236,8 +236,8 @@ Test.prototype._assert = function assert(ok, opts) { for (var i = 0; i < err.length; i++) { /* Stack trace lines may resemble one of the following. We need - to should correctly extract a function name (if any) and - path / line no. for each line. + to correctly extract a function name (if any) and path / line + number for each line. at myFunction (/path/to/file.js:123:45) at myFunction (/path/to/file.other-ext:123:45) @@ -267,9 +267,9 @@ Test.prototype._assert = function assert(ok, opts) { Last part captures file path plus line no (and optional column no). - /((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)/ + /((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)\)?/ */ - var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)\)$/; + var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)\)?$/; var lineWithTokens = err[i].replace(process.cwd(), '/\$CWD').replace(__dirname, '/\$TEST'); var m = re.exec(lineWithTokens); diff --git a/test/anonymous-fn.js b/test/anonymous-fn.js index 3e5da152..a402eb9c 100644 --- a/test/anonymous-fn.js +++ b/test/anonymous-fn.js @@ -18,7 +18,7 @@ tap.test('inside anonymous functions', function (tt) { 'not ok 1 fail', ' ---', ' operator: fail', - ' at: Test. ($TEST/anonymous-fn/test-wrapper.js:$LINE:$COL)', + ' at: ($TEST/anonymous-fn.js:$LINE:$COL)', ' stack: |-', ' Error: fail', ' [... stack stripped ...]', diff --git a/test/exit.js b/test/exit.js index 686c3da9..4ba1f9a5 100644 --- a/test/exit.js +++ b/test/exit.js @@ -52,7 +52,7 @@ tap.test('exit fail', function (t) { ' operator: deepEqual', ' expected: [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]', ' actual: [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]', - ' at: Test. ($TEST/exit/fail.js:$LINE:$COL)', + ' at: ($TEST/exit/fail.js:$LINE:$COL)', ' stack: |-', ' Error: should be equivalent', ' [... stack stripped ...]', diff --git a/test/fail.js b/test/fail.js index 96769341..580e40a0 100644 --- a/test/fail.js +++ b/test/fail.js @@ -22,7 +22,7 @@ tap.test('array test', function (tt) { ' operator: deepEqual', ' expected: [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]', ' actual: [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]', - ' at: Test. ($TEST/fail.js:$LINE:$COL)', + ' at: ($TEST/fail.js:$LINE:$COL)', ' stack: |-', ' Error: should be equivalent', ' [... stack stripped ...]', diff --git a/test/stackTrace.js b/test/stackTrace.js index 54298184..f2e4b4e2 100644 --- a/test/stackTrace.js +++ b/test/stackTrace.js @@ -68,8 +68,8 @@ tap.test('preserves stack trace with newlines', function (tt) { }); }); -tap.test('parses function name from original stack', function (tt) { - tt.plan(1); +tap.test('parses function info from original stack', function (tt) { + tt.plan(4); var test = tape.createHarness(); test.createStream(); @@ -77,6 +77,9 @@ tap.test('parses function name from original stack', function (tt) { test._results._watch = function (t) { t.on('result', function (res) { tt.equal('Test.testFunctionNameParsing', res.functionName); + tt.match(res.file, /stackTrace.js/i); + tt.ok(Number(res.line) > 0); + tt.ok(Number(res.column) > 0); }); }; @@ -86,8 +89,8 @@ tap.test('parses function name from original stack', function (tt) { }); }); -tap.test('parses function name from original stack for anonymous function', function (tt) { - tt.plan(1); +tap.test('parses function info from original stack for anonymous function', function (tt) { + tt.plan(4); var test = tape.createHarness(); test.createStream(); @@ -95,6 +98,9 @@ tap.test('parses function name from original stack for anonymous function', func test._results._watch = function (t) { t.on('result', function (res) { tt.equal('Test.', res.functionName); + tt.match(res.file, /stackTrace.js/i); + tt.ok(Number(res.line) > 0); + tt.ok(Number(res.column) > 0); }); }; @@ -104,6 +110,60 @@ tap.test('parses function name from original stack for anonymous function', func }); }); +if (typeof Promise === 'function' && typeof Promise.resolve === 'function') { + + tap.test('parses function info from original stack for Promise scenario', function (tt) { + tt.plan(4); + + var test = tape.createHarness(); + test.createStream(); + + test._results._watch = function (t) { + t.on('result', function (res) { + tt.equal('onfulfilled', res.functionName); + tt.match(res.file, /stackTrace.js/i); + tt.ok(Number(res.line) > 0); + tt.ok(Number(res.column) > 0); + }); + }; + + test('t.equal stack trace', function testFunctionNameParsing(t) { + new Promise(function (resolve) { + resolve(); + }).then(function onfulfilled() { + t.equal(true, false, 'true should be false'); + t.end(); + }); + }); + }); + + tap.test('parses function info from original stack for Promise scenario with anonymous function', function (tt) { + tt.plan(4); + + var test = tape.createHarness(); + test.createStream(); + + test._results._watch = function (t) { + t.on('result', function (res) { + tt.equal('', res.functionName); + tt.match(res.file, /stackTrace.js/i); + tt.ok(Number(res.line) > 0); + tt.ok(Number(res.column) > 0); + }); + }; + + test('t.equal stack trace', function testFunctionNameParsing(t) { + new Promise(function (resolve) { + resolve(); + }).then(function () { + t.equal(true, false, 'true should be false'); + t.end(); + }); + }); + }); + +} + tap.test('preserves stack trace for failed assertions', function (tt) { tt.plan(6); diff --git a/test/too_many.js b/test/too_many.js index a3a780a2..946ceb8e 100644 --- a/test/too_many.js +++ b/test/too_many.js @@ -22,7 +22,7 @@ tap.test('array test', function (tt) { ' operator: fail', ' expected: 3', ' actual: 4', - ' at: Test. ($TEST/too_many.js:$LINE:$COL)', + ' at: ($TEST/too_many.js:$LINE:$COL)', ' stack: |-', ' Error: plan != count', ' [... stack stripped ...]', From 582fe0057de5f8c18eb3096bbe89915d33be084d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 24 May 2020 14:05:06 -0700 Subject: [PATCH 07/10] [Fix] `createStream`: `result` payload is not always an object (#519) Fixes #519. --- lib/results.js | 6 +++-- test/objectMode.js | 3 +-- test/objectModeWithComment.js | 41 +++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 test/objectModeWithComment.js diff --git a/lib/results.js b/lib/results.js index 40e85911..89da4b0a 100644 --- a/lib/results.js +++ b/lib/results.js @@ -58,8 +58,10 @@ Results.prototype.createStream = function (opts) { ontest(st, { parent: id }); }); t.on('result', function (res) { - res.test = id; - res.type = 'assert'; + if (res && typeof res === 'object') { + res.test = id; + res.type = 'assert'; + } output.queue(res); }); t.on('end', function () { diff --git a/test/objectMode.js b/test/objectMode.js index d9e1f6eb..33df4661 100644 --- a/test/objectMode.js +++ b/test/objectMode.js @@ -47,8 +47,7 @@ tap.test('object results', function (assert) { assert.end(); }; - tape.createStream({ objectMode: true }) - .pipe(printer); + tape.createStream({ objectMode: true }).pipe(printer); tape('parent', function (t1) { t1.equal(true, true); diff --git a/test/objectModeWithComment.js b/test/objectModeWithComment.js new file mode 100644 index 00000000..9a34f270 --- /dev/null +++ b/test/objectModeWithComment.js @@ -0,0 +1,41 @@ +'use strict'; + +var tap = require('tap'); +var tape = require('../'); +var through = require('through'); + +tap.test('test.comment() in objectMode', function (assert) { + var printer = through({ objectMode: true }); + var objects = []; + printer.on('error', function (e) { + assert.fail(e); + }); + + printer.write = function (obj) { + objects.push(obj); + }; + printer.end = function (obj) { + if (obj) { objects.push(obj); } + + assert.equal(objects.length, 3); + assert.deepEqual(objects, [ + { + type: 'test', + name: 'test.comment', + id: 0, + skip: false, + todo: false + }, + 'message', + { type: 'end', test: 0 } + ]); + assert.end(); + }; + + tape.createStream({ objectMode: true }).pipe(printer); + + tape('test.comment', function (test) { + test.comment('message'); + test.end(); + }); +}); From 8887189c60d956f13f7b54497443bb4be2726748 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 24 May 2020 14:10:39 -0700 Subject: [PATCH 08/10] [Deps] update `minimist`, `resolve` --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c3f14bbb..744be41a 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,9 @@ "has": "~1.0.3", "inherits": "~2.0.4", "is-regex": "~1.0.5", - "minimist": "~1.2.0", + "minimist": "~1.2.5", "object-inspect": "~1.7.0", - "resolve": "~1.15.1", + "resolve": "~1.17.0", "resumer": "~0.0.0", "string.prototype.trim": "~1.2.1", "through": "~2.3.8" From 9676a21784a90a13e29505d86901cd1cd0c1c7db Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 24 May 2020 14:13:02 -0700 Subject: [PATCH 09/10] [Dev Deps] update `eslint`, `falafel`, `js-yaml` --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 744be41a..f67f4a93 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,9 @@ "concat-stream": "^1.6.2", "eclint": "^2.8.1", "ecstatic": "^4.1.4", - "eslint": "^6.8.0", - "falafel": "^2.1.0", - "js-yaml": "^3.13.1", + "eslint": "^7.1.0", + "falafel": "^2.2.4", + "js-yaml": "^3.14.0", "tap": "^8.0.1", "tap-parser": "^3.0.5" }, From a8612306bb8d8a292b8f1c4163e47bd27deaf470 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 24 May 2020 14:27:35 -0700 Subject: [PATCH 10/10] v4.13.3 - [Fix] `createStream`: `result` payload is not always an object (#519) - [Fix] Update RegExp for matching stack frames to handle Promise/then scenario (#516) - [readme] add `tape-repeater` (#511) - [readme] Add link to tape-player (in-process reporter) (#496) - [examples] add `ecstatic` - [Docs] add an optional emoji version for tap-spec consumer (#501) - [Deps] update `minimist`, `resolve` - [Tests] Fix simple typo, placehodler -> placeholder (#500) - [Dev Deps] update `eslint`, `falafel`, `js-yaml` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f67f4a93..8ba3a13e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tape", - "version": "4.13.2", + "version": "4.13.3", "description": "tap-producing test harness for node and browsers", "main": "index.js", "bin": "./bin/tape",