Comparing version 5.8.0 to 5.8.1
@@ -975,3 +975,3 @@ 'use strict'; | ||
Test.prototype.assertion = function assertion(fn) { | ||
callBind.apply(fn)(this, $slice(arguments, 1)); | ||
return callBind.apply(fn)(this, $slice(arguments, 1)); | ||
}; | ||
@@ -978,0 +978,0 @@ |
{ | ||
"name": "tape", | ||
"version": "5.8.0", | ||
"version": "5.8.1", | ||
"description": "tap-producing test harness for node and browsers", | ||
@@ -64,2 +64,3 @@ "main": "index.js", | ||
"safe-publish-latest": "^2.0.0", | ||
"semver": "^6.3.1", | ||
"tap": "^8.0.1", | ||
@@ -100,5 +101,5 @@ "tap-parser": "^5.4.0" | ||
"type": "git", | ||
"url": "git://github.com/tape-testling/tape.git" | ||
"url": "git://github.com/tape-testing/tape.git" | ||
}, | ||
"homepage": "https://github.com/tape-testling/tape", | ||
"homepage": "https://github.com/tape-testing/tape", | ||
"keywords": [ | ||
@@ -105,0 +106,0 @@ "tap", |
@@ -6,2 +6,3 @@ 'use strict'; | ||
var concat = require('concat-stream'); | ||
var satisfies = require('semver').satisfies; | ||
@@ -36,7 +37,24 @@ var stripFullStack = require('./common').stripFullStack; | ||
' ...', | ||
typeof Promise === 'undefined' | ||
? '# SKIP custom assertion returns a promise' | ||
: [].concat( | ||
'# custom assertion returns a promise', | ||
'ok ' + ++count + ' promise rejected!', | ||
'not ok ' + ++count + ' SyntaxError: expected promise to reject; it fulfilled', | ||
' ---', | ||
' operator: error', | ||
' stack: |-', | ||
' SyntaxError: expected promise to reject; it fulfilled', | ||
' at $TEST/assertion.js:$LINE:$COL', | ||
satisfies(process.version, '^8 || ^9') | ||
? ' at <anonymous>' | ||
: [], | ||
' [... stack stripped ...]', | ||
' ...' | ||
), | ||
'', | ||
'1..' + count, | ||
'# tests ' + count, | ||
'# pass ' + (count - 1), | ||
'# fail 1', | ||
'# pass ' + (count - (typeof Promise === 'undefined' ? 1 : 2)), | ||
'# fail ' + (typeof Promise === 'undefined' ? 1 : 2), | ||
'' | ||
@@ -47,3 +65,3 @@ )); | ||
var isAnswer = function (value, msg) { | ||
// eslint-disable-next-line no-invalid-this | ||
this.equal(value, 42, msg || 'value must be the answer to life, the universe, and everything'); | ||
@@ -60,2 +78,31 @@ }; | ||
}); | ||
var rejects = function assertRejects(fn, expected, msg, extra) { | ||
var t = this; | ||
/* eslint no-invalid-this: 0 */ | ||
return new Promise(function (resolve) { resolve(fn()); }).then( | ||
function () { | ||
throw new SyntaxError('expected promise to reject; it fulfilled'); | ||
}, | ||
function (err) { | ||
t['throws'](function () { throw err; }, expected, msg, extra); | ||
} | ||
); | ||
}; | ||
test('custom assertion returns a promise', { skip: typeof Promise !== 'function' }, function (t) { | ||
return Promise.all([ | ||
t.assertion( | ||
rejects, | ||
function () { return Promise.resolve(); }, | ||
SyntaxError, | ||
'expected promise to reject; it fulfilled' | ||
), | ||
t.assertion( | ||
rejects, | ||
function () { return Promise.reject(new Error('foo')); }, | ||
'promise rejected!' | ||
) | ||
]); | ||
}); | ||
}); |
@@ -98,6 +98,11 @@ 'use strict'; | ||
).replace( | ||
// Handle stack trace variation in Node v0.8 | ||
// Handle more stack trace variation in Node v0.8 | ||
/(\[\.\.\. stack stripped \.\.\.\]\r?\n *at) <anonymous> \(([^)]+)\)/g, | ||
'$1 $2' | ||
).split(/\r?\n/g); | ||
).replace( | ||
// Handle more stack trace variation in Node v0.8 | ||
/at(:?) Test\.t /g, | ||
'at$1 Test.<anonymous> ' | ||
) | ||
.split(/\r?\n/g); | ||
}; | ||
@@ -104,0 +109,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
430285
7930
0
20