Comparing version 7.0.0 to 7.1.0
@@ -60,3 +60,3 @@ import {current} from './tst.js' | ||
export function almost (a, b, eps, msg = 'should almost equal') { | ||
export function almost (a, b, eps = 1.19209290e-7, msg = 'should almost equal') { | ||
if ( | ||
@@ -80,5 +80,7 @@ isPrimitive(a) || isPrimitive(b) ? almostEqual(a, b, eps) : | ||
} catch (err) { | ||
if (err instanceof Assertion) throw err; | ||
if (expects instanceof Error) { | ||
if (err.name === expects.name) return current?.pass({operator: 'throws', message: msg}) | ||
throw Assertion({ | ||
throw new Assertion({ | ||
operator: 'throws', | ||
@@ -91,3 +93,3 @@ message: msg, | ||
if (expects.test(err.toString())) return current?.pass({operator: 'throws', message: msg}) | ||
throw Assertion({ | ||
throw new Assertion({ | ||
operator: 'throws', | ||
@@ -100,3 +102,3 @@ message: msg, | ||
if (expects(err)) return current?.pass({operator: 'throws', message: msg}) | ||
throw Assertion({ | ||
throw new Assertion({ | ||
operator: 'throws', | ||
@@ -107,2 +109,3 @@ message: msg, | ||
} | ||
return current?.pass({operator: 'throws', message: msg}) | ||
@@ -109,0 +112,0 @@ } |
{ | ||
"name": "tst", | ||
"description": "Tests without efforts", | ||
"version": "7.0.0", | ||
"version": "7.1.0", | ||
"repository": "dy/tst", | ||
@@ -6,0 +6,0 @@ "author": "Dmitry Iv.", |
@@ -12,3 +12,4 @@ # tst | ||
* correct stacktrace with sourcemaps | ||
* better look & feel | ||
* nice look & feel in browser/node | ||
* tiny bundle, 0dep | ||
@@ -77,3 +78,4 @@ ## Usage | ||
* [@goto-bus-stop/tape-modern](https://github.com/goto-bus-stop/tape-modern#readme) | ||
* [brittle](https://github.com/davidmarkclements/brittle) | ||
<p align="center">🕉️</p> |
26
tst.js
const GREEN = '\u001b[32m', RED = '\u001b[31m', YELLOW = '\u001b[33m', RESET = '\u001b[0m', CYAN = '\u001b[36m', GRAY = '\u001b[30m' | ||
const isNode = typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]' | ||
let assertIndex = 0 | ||
let index = 1 | ||
let passed = 0 | ||
let failed = 0 | ||
let skipped = 0 | ||
let only = 0 | ||
let current = null | ||
let assertIndex = 0, | ||
index = 1, | ||
passed = 0, | ||
failed = 0, | ||
skipped = 0, | ||
only = 0, | ||
current = null, | ||
start, | ||
queue = new Promise(resolve => start = resolve) | ||
export {current} | ||
let start | ||
let queue = new Promise(resolve => start = resolve) | ||
@@ -68,3 +69,3 @@ export default function test(name, run) { | ||
assertIndex += 1 | ||
assertIndex++ | ||
isNode ? | ||
@@ -79,2 +80,4 @@ console.log(`${GREEN}√ ${assertIndex} ${op && `(${op})`} — ${msg}${RESET}`) : | ||
fail(arg) { | ||
assertIndex++ | ||
// FIXME: this syntax is due to chrome not always able to grasp the stack trace from source maps | ||
@@ -101,3 +104,3 @@ // console.error(RED + arg.stack, RESET) | ||
test.assertion.push({ idx: assertIndex, msg, info, error: new Error() }) | ||
failed += 1 | ||
// failed += 1 | ||
// } | ||
@@ -139,2 +142,3 @@ } | ||
// tests called via import() cause network delay, hopefully 100ms is ok | ||
// TODO: do run? with silent=false flag? | ||
Promise.all([ | ||
@@ -141,0 +145,0 @@ new Promise(resolve => (typeof setImmediate !== 'undefined' ? setImmediate : requestIdleCallback)(resolve)), |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
286
80
0
13830
5