Comparing version 3.0.0 to 3.0.1
33
index.js
@@ -31,3 +31,3 @@ import * as assert from './assert.js' | ||
if (!fn) return test.todo(name) | ||
tests.push({ name, fn, skip: false, only: false, shouldRun: false }) | ||
tests.push({ name, fn, skip: false, only: false, shouldRun: false, results: [] }) | ||
start() | ||
@@ -37,7 +37,7 @@ } | ||
test.todo = function (name, fn) { | ||
tests.push({ name, fn, skip: true, todo: true, only: false, shouldRun: null }) | ||
tests.push({ name, fn, skip: true, todo: true, only: false, shouldRun: null, results: [] }) | ||
} | ||
test.skip = function (name, fn) { | ||
tests.push({ name, fn, skip: true, only: false, shouldRun: null }) | ||
tests.push({ name, fn, skip: true, only: false, shouldRun: null, results: [] }) | ||
start() | ||
@@ -47,3 +47,3 @@ } | ||
test.only = function (name, fn) { | ||
tests.push({ name, fn, skip: false, only: true, shouldRun: null }) | ||
tests.push({ name, fn, skip: false, only: true, shouldRun: null, results: [] }) | ||
start() | ||
@@ -61,2 +61,4 @@ } | ||
export let current = null // current test | ||
const isNode = typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]' | ||
@@ -67,7 +69,9 @@ | ||
if (ok) { | ||
console.log(`%c ✔ ${assertIndex} — ${msg}`, 'color: #229944') | ||
current.results.push({ idx: assertIndex, msg }) | ||
// console.log(`%c ✔ ${assertIndex} — ${msg}`, 'color: #229944') | ||
passed += 1 | ||
} else { | ||
current.results.push({ idx: assertIndex, msg, info, error: new Error() }) | ||
failed += 1 | ||
console.assert(false, `${assertIndex} — ${msg}`, info, (new Error())) | ||
// console.assert(false, `${assertIndex} — ${msg}`, info, (new Error())) | ||
} | ||
@@ -92,8 +96,8 @@ } | ||
try { | ||
let from = new Date() | ||
current = test | ||
let from = performance.now() | ||
await test.fn(assert) | ||
let time = new Date() - from | ||
console.log(`# ${test.name} (${time}ms)`) | ||
let time = performance.now() - from | ||
console.log(`# ${test.name} (${time.toPrecision(3)}ms)`) | ||
} catch (err) { | ||
@@ -105,2 +109,11 @@ console.log(`# ${test.name}`) | ||
} | ||
finally { | ||
current.results.forEach(res => { | ||
if (res.error) { | ||
console.assert(false, `${res.idx} — ${res.msg}`, res.info, res.error) | ||
} else { | ||
console.log(`%c ✔ ${res.idx} — ${res.msg}`, 'color: #229944') | ||
} | ||
}) | ||
} | ||
@@ -107,0 +120,0 @@ dequeue() |
{ | ||
"name": "tst", | ||
"description": "Testing tool", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"repository": "dy/tst", | ||
@@ -6,0 +6,0 @@ "author": "Dmitry Yv", |
@@ -7,5 +7,6 @@ # tst | ||
* inspectable logs | ||
* relevant stacktrace | ||
* correct stacktrace | ||
* `deepEqual` <!-- almost, same --> | ||
* muted skipped | ||
* time measurement | ||
@@ -12,0 +13,0 @@ ## Usage |
8748
207
49
201