tape
Advanced tools
Comparing version 5.7.2 to 5.7.3
32
index.js
@@ -6,3 +6,3 @@ 'use strict'; | ||
var Test = require('./lib/test'); | ||
var createResult = require('./lib/results'); | ||
var Results = require('./lib/results'); | ||
var through = require('@ljharb/through'); | ||
@@ -20,7 +20,7 @@ | ||
function getHarness(opts) { | ||
if (!opts) { opts = {}; } | ||
opts.autoclose = !canEmitExit; | ||
// this override is here since tests fail via nyc if createHarness is moved upwards | ||
// eslint-disable-next-line no-use-before-define | ||
if (!harness) { harness = createExitHarness(opts, wait); } | ||
if (!harness) { | ||
// eslint-disable-next-line no-use-before-define | ||
harness = createExitHarness(opts || {}, wait); | ||
} | ||
return harness; | ||
@@ -72,3 +72,3 @@ } | ||
function createHarness(conf_) { | ||
var results = createResult(); | ||
var results = new Results(); | ||
if (!conf_ || conf_.autoclose !== false) { | ||
@@ -113,3 +113,3 @@ results.once('done', function () { results.close(); }); | ||
if (only) { throw new Error('there can only be one only test'); } | ||
if (conf_.noOnly) { throw new Error('`only` tests are prohibited'); } | ||
if (conf_ && conf_.noOnly) { throw new Error('`only` tests are prohibited'); } | ||
only = true; | ||
@@ -127,7 +127,11 @@ var t = test.apply(null, arguments); | ||
function createExitHarness(conf, wait) { | ||
var config = conf || {}; | ||
function createExitHarness(config, wait) { | ||
var noOnly = config.noOnly; | ||
var objectMode = config.objectMode; | ||
var cStream = config.stream; | ||
var exit = config.exit; | ||
var harness = createHarness({ | ||
autoclose: defined(config.autoclose, false), | ||
noOnly: defined(conf.noOnly, defined(process.env.NODE_TAPE_NO_ONLY_TEST, false)) | ||
autoclose: !canEmitExit, | ||
noOnly: defined(noOnly, defined(process.env.NODE_TAPE_NO_ONLY_TEST, false)) | ||
}); | ||
@@ -140,4 +144,4 @@ var running = false; | ||
running = true; | ||
var stream = harness.createStream({ objectMode: config.objectMode }); | ||
var es = stream.pipe(config.stream || createDefaultStream()); | ||
var stream = harness.createStream({ objectMode: objectMode }); | ||
var es = stream.pipe(cStream || createDefaultStream()); | ||
if (canEmitExit && es) { // in node v0.4, `es` is `undefined` | ||
@@ -157,3 +161,3 @@ // TODO: use `err` arg? | ||
if (config.exit === false) { return harness; } | ||
if (exit === false) { return harness; } | ||
if (!canEmitExit || !canExit) { return harness; } | ||
@@ -160,0 +164,0 @@ |
@@ -116,3 +116,2 @@ 'use strict'; | ||
self.on('_push', function ontest(t, extra) { | ||
if (!extra) { extra = {}; } | ||
var id = testId++; | ||
@@ -127,3 +126,3 @@ t.once('prerun', function () { | ||
}; | ||
if (hasOwn(extra, 'parent')) { | ||
if (extra && hasOwn(extra, 'parent')) { | ||
row.parent = extra.parent; | ||
@@ -173,6 +172,5 @@ } | ||
Results.prototype.push = function (t) { | ||
var self = this; | ||
$push(self.tests, t); | ||
self._watch(t); | ||
self.emit('_push', t); | ||
$push(this.tests, t); | ||
this._watch(t); | ||
this.emit('_push', t); | ||
}; | ||
@@ -179,0 +177,0 @@ |
@@ -224,3 +224,3 @@ 'use strict'; | ||
try { | ||
var returned = original ? bound(this, arguments) : void undefined; | ||
var returned = bound ? bound(this, arguments) : void undefined; | ||
$push(calls, { args: args, receiver: this, returned: returned }); | ||
@@ -352,3 +352,3 @@ completed = true; | ||
if (!canSet && strictMode) { | ||
throw new TypeError('Cannot assign to read only property \'' + property + '\' of object \'' + inspect(obj) + '\''); | ||
throw new TypeError('Cannot assign to read only property `' + inspect(property) + '` of object `' + inspect(obj) + '`'); | ||
} | ||
@@ -455,3 +455,3 @@ return value; | ||
ok = !!ok || !!extra.skip; | ||
var actualOK = !!ok || !!extra.skip; | ||
@@ -466,3 +466,3 @@ var name = defined(extra.message, opts.message, '(unnamed assert)'); | ||
id: self.assertCount++, | ||
ok: ok, | ||
ok: actualOK, | ||
skip: defined(extra.skip, opts.skip), | ||
@@ -480,12 +480,12 @@ todo: defined(extra.todo, opts.todo, self._todo), | ||
} | ||
this._ok = !!(this._ok && ok); | ||
this._ok = !!(this._ok && actualOK); | ||
if (!ok && !res.todo) { | ||
if (!actualOK && !res.todo) { | ||
res.error = defined(extra.error, opts.error, new Error(res.name)); | ||
} | ||
if (!ok) { | ||
if (!actualOK) { | ||
var e = new Error('exception'); | ||
var err = $split(e.stack || '', '\n'); | ||
var dir = __dirname + path.sep; | ||
var tapeDir = __dirname + path.sep; | ||
@@ -526,6 +526,15 @@ for (var i = 0; i < err.length; i++) { | ||
/((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)\)?/ | ||
/((?:[/\\]|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)\)?/ | ||
*/ | ||
var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:\/|[a-zA-Z]:\\)[^:)]+:(\d+)(?::(\d+))?)\)?$/; | ||
var lineWithTokens = $replace($replace(err[i], process.cwd(), '/$CWD'), __dirname, '/$TEST'); | ||
var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:[/\\]|[a-zA-Z]:\\)[^:)]+:(\d+)(?::(\d+))?)\)?$/; | ||
// first tokenize the PWD, then tokenize tape | ||
var lineWithTokens = $replace( | ||
$replace( | ||
err[i], | ||
process.cwd(), | ||
path.sep + '$CWD' | ||
), | ||
tapeDir, | ||
path.sep + '$TEST' + path.sep | ||
); | ||
var m = re.exec(lineWithTokens); | ||
@@ -538,5 +547,14 @@ | ||
var callDescription = m[1] || '<anonymous>'; | ||
var filePath = $replace($replace(m[2], '/$CWD', process.cwd()), '/$TEST', __dirname); | ||
// first untokenize tape, and then untokenize the PWD, then strip the line/column | ||
var filePath = $replace( | ||
$replace( | ||
$replace(m[2], path.sep + '$TEST' + path.sep, tapeDir), | ||
path.sep + '$CWD', | ||
process.cwd() | ||
), | ||
/:\d+:\d+$/, | ||
'' | ||
); | ||
if ($strSlice(filePath, 0, dir.length) === dir) { | ||
if ($strSlice(filePath, 0, tapeDir.length) === tapeDir) { | ||
continue; | ||
@@ -552,3 +570,3 @@ } | ||
res.at = callDescription + ' (' + filePath + ')'; | ||
res.at = callDescription + ' (' + filePath + ':' + res.line + (res.column ? ':' + res.column : '') + ')'; | ||
break; | ||
@@ -555,0 +573,0 @@ } |
{ | ||
"name": "tape", | ||
"version": "5.7.2", | ||
"version": "5.7.3", | ||
"description": "tap-producing test harness for node and browsers", | ||
@@ -23,2 +23,3 @@ "main": "index.js", | ||
"bin": "./bin/tape", | ||
"sideEffects": false, | ||
"directories": { | ||
@@ -33,3 +34,3 @@ "example": "example", | ||
"call-bind": "^1.0.5", | ||
"deep-equal": "^2.2.2", | ||
"deep-equal": "^2.2.3", | ||
"defined": "^1.0.1", | ||
@@ -45,7 +46,7 @@ "dotignore": "^0.1.2", | ||
"minimist": "^1.2.8", | ||
"mock-property": "^1.0.2", | ||
"mock-property": "^1.0.3", | ||
"object-inspect": "^1.13.1", | ||
"object-is": "^1.1.5", | ||
"object-keys": "^1.1.1", | ||
"object.assign": "^4.1.4", | ||
"object.assign": "^4.1.5", | ||
"resolve": "^2.0.0-next.5", | ||
@@ -57,3 +58,3 @@ "string.prototype.trim": "^1.2.8" | ||
"array.prototype.flatmap": "^1.3.2", | ||
"aud": "^2.0.3", | ||
"aud": "^2.0.4", | ||
"auto-changelog": "^2.4.0", | ||
@@ -70,3 +71,4 @@ "concat-stream": "^1.6.2", | ||
"npm-run-posix-or-windows": "^2.0.2", | ||
"npmignore": "^0.3.0", | ||
"npmignore": "^0.3.1", | ||
"nyc": "^10.3.2", | ||
"safe-publish-latest": "^2.0.0", | ||
@@ -88,5 +90,6 @@ "tap": "^8.0.1", | ||
"pretest": "npm run lint", | ||
"test": "npm run tests-only", | ||
"test": "npm-run-posix-or-windows tests-only", | ||
"posttest": "aud --production", | ||
"tests-only": "nyc tap 'test/*.js'", | ||
"tests-only:windows": "nyc node_modules\\tap\\bin\\run.js test/*.js", | ||
"test:example": "find example -name '*.js' | grep -v fail | grep -v static | xargs tap" | ||
@@ -93,0 +96,0 @@ }, |
@@ -6,10 +6,8 @@ 'use strict'; | ||
tap.test('main harness object is exposed', function (assert) { | ||
tap.test('main harness object is exposed', function (tt) { | ||
tt.equal(typeof tape.getHarness, 'function', 'tape.getHarness is a function'); | ||
assert.equal(typeof tape.getHarness, 'function', 'tape.getHarness is a function'); | ||
tt.equal(tape.getHarness()._results.pass, 0); | ||
assert.equal(tape.getHarness()._results.pass, 0); | ||
assert.end(); | ||
tt.end(); | ||
}); |
@@ -12,3 +12,3 @@ 'use strict'; | ||
tap.test('Should pass with ignoring', { skip: process.platform === 'win32' }, function (tt) { | ||
tap.test('Should pass with ignoring', function (tt) { | ||
tt.plan(2); | ||
@@ -42,3 +42,3 @@ | ||
var ps = spawn(tapeBin, ['**/*.js', '-i', '.ignore'], { cwd: path.join(__dirname, 'ignore') }); | ||
var ps = spawn(process.execPath, [tapeBin, '**/*.js', '-i', '.ignore'], { cwd: path.join(__dirname, 'ignore') }); | ||
ps.stdout.pipe(concat(tc)); | ||
@@ -50,3 +50,3 @@ ps.on('exit', function (code) { | ||
tap.test('Should pass', { skip: process.platform === 'win32' }, function (tt) { | ||
tap.test('Should pass', function (tt) { | ||
tt.plan(2); | ||
@@ -101,3 +101,3 @@ | ||
var ps = spawn(tapeBin, ['**/*.js'], { cwd: path.join(__dirname, 'ignore') }); | ||
var ps = spawn(process.execPath, [tapeBin, '**/*.js'], { cwd: path.join(__dirname, 'ignore') }); | ||
ps.stdout.pipe(concat(tc)); | ||
@@ -109,3 +109,3 @@ ps.on('exit', function (code) { | ||
tap.test('Should fail when ignore file does not exist', { skip: process.platform === 'win32' }, function (tt) { | ||
tap.test('Should fail when ignore file does not exist', function (tt) { | ||
tt.plan(3); | ||
@@ -121,3 +121,3 @@ | ||
var ps = spawn(tapeBin, ['**/*.js', '-i'], { cwd: path.join(__dirname, 'ignore') }); | ||
var ps = spawn(process.execPath, [tapeBin, '**/*.js', '-i'], { cwd: path.join(__dirname, 'ignore') }); | ||
ps.stdout.pipe(concat(testStdout)); | ||
@@ -124,0 +124,0 @@ ps.stderr.pipe(concat(testStderr)); |
@@ -11,3 +11,3 @@ 'use strict'; | ||
tt.plan(1); | ||
var proc = execFile(tapeBin, ['--ignore', '.ignore', '--ignore-pattern', 'fake_other_ignored_dir', '**/*.js'], { cwd: path.join(__dirname, 'ignore-pattern') }); | ||
var proc = execFile(process.execPath, [tapeBin, '--ignore', '.ignore', '--ignore-pattern', 'fake_other_ignored_dir', '**/*.js'], { cwd: path.join(__dirname, 'ignore-pattern') }); | ||
@@ -21,3 +21,3 @@ proc.on('exit', function (code) { | ||
tt.plan(1); | ||
var proc = execFile(tapeBin, ['--ignore-pattern', 'fake_*', '**/*.js'], { cwd: path.join(__dirname, 'ignore-pattern') }); | ||
var proc = execFile(process.execPath, [tapeBin, '--ignore-pattern', 'fake_*', '**/*.js'], { cwd: path.join(__dirname, 'ignore-pattern') }); | ||
@@ -31,3 +31,3 @@ proc.on('exit', function (code) { | ||
tt.plan(1); | ||
var proc = execFile(tapeBin, ['**/*.js'], { cwd: path.join(__dirname, 'ignore-pattern') }); | ||
var proc = execFile(process.execPath, [tapeBin, '**/*.js'], { cwd: path.join(__dirname, 'ignore-pattern') }); | ||
@@ -34,0 +34,0 @@ proc.on('exit', function (code) { |
@@ -12,3 +12,3 @@ 'use strict'; | ||
return spawn('node', [bin].concat(args.split(' ')), assign({ cwd: __dirname }, options)); | ||
return spawn(process.execPath, [bin].concat(args.split(' ')), assign({ cwd: __dirname }, options)); | ||
} | ||
@@ -15,0 +15,0 @@ |
@@ -46,2 +46,8 @@ 'use strict'; | ||
'ok ' + ++count + ' undefined is still returned from Get', | ||
v.hasSymbols ? [ | ||
'ok ' + ++count + ' nonwritable Symbol property throws on Set', | ||
'ok ' + ++count + ' undefined is still returned from Get of a Symbol' | ||
] : [ | ||
'ok ' + ++count + ' undefined is still returned from Get of a Symbol # SKIP no Symbol support' | ||
], | ||
'ok ' + ++count + ' throwing get implementation throws', | ||
@@ -170,2 +176,21 @@ 'ok ' + ++count + ' throwing get implementation throws with .call', | ||
if (v.hasSymbols) { | ||
var sym = Symbol('fooSymbol'); | ||
var resultsSymbol = st.intercept( | ||
o, | ||
sym, | ||
{ __proto__: null, writable: false }, | ||
true | ||
); | ||
st.throws( | ||
function () { o[sym] = 42; }, | ||
new RegExp('^TypeError: Cannot assign to read only property `Symbol\\(fooSymbol\\)` of object `' + inspect(o) + '`$'), | ||
'nonwritable Symbol property throws on Set' | ||
); | ||
st.equal(o[sym], undefined, 'undefined is still returned from Get of a Symbol'); | ||
resultsSymbol.restore(); | ||
} else { | ||
st.equal(undefined, undefined, 'undefined is still returned from Get of a Symbol', { skip: 'no Symbol support' }); | ||
} | ||
var resultsThrowGet = st.intercept(o, 'fooThrowGet', { get: function () { throw up; } }); | ||
@@ -172,0 +197,0 @@ st.throws( |
@@ -49,1 +49,9 @@ 'use strict'; | ||
}); | ||
tap.test('created harness with no conf', function (tt) { | ||
var harness = tape.createHarness(); | ||
tt.doesNotThrow(function () { harness.only({ skip: true }); }, 'harness.only does not throw with omitted harness conf arg'); | ||
tt.end(); | ||
}); |
@@ -11,3 +11,3 @@ 'use strict'; | ||
return spawn('node', [bin].concat(args.split(' ')), { cwd: __dirname }); | ||
return spawn(process.execPath, [bin].concat(args.split(' ')), { cwd: __dirname }); | ||
} | ||
@@ -14,0 +14,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
402654
7508
19
Updateddeep-equal@^2.2.3
Updatedmock-property@^1.0.3
Updatedobject.assign@^4.1.5