Comparing version 4.2.0 to 4.2.1
24
index.js
@@ -13,3 +13,3 @@ import * as assert from './assert.js' | ||
class Test extends Promise { | ||
constructor (o) { | ||
constructor(o) { | ||
let resolve, reject | ||
@@ -35,12 +35,9 @@ super((ok, nok) => { | ||
async run() { | ||
let result | ||
try { | ||
this.resolve(result = await this.fn(this)) | ||
let result = this.fn(this) | ||
if (result && result.then) { | ||
return result.then(this.resolve, this.reject) | ||
} | ||
catch (e) { | ||
this.reject() | ||
else { | ||
this.resolve(result) | ||
} | ||
finally { | ||
this.end() | ||
} | ||
return result | ||
@@ -73,3 +70,3 @@ } | ||
export default function test (name, fn) { | ||
export default function test(name, fn) { | ||
if (!fn) return test.todo(name) | ||
@@ -111,3 +108,3 @@ return new Test({ name, fn }) | ||
async function dequeue () { | ||
async function dequeue() { | ||
if (tests.length) { | ||
@@ -140,3 +137,2 @@ const test = tests.shift() | ||
await test.run() | ||
console.groupEnd() | ||
} catch (err) { | ||
@@ -146,2 +142,4 @@ failed += 1 | ||
console.error(err.stack) | ||
} finally { | ||
if (!isNode) console.groupEnd() | ||
} | ||
@@ -156,3 +154,3 @@ | ||
if (only) console.log(`# only ${only} cases`) | ||
console.log(`# total ${ total }`) | ||
console.log(`# total ${total}`) | ||
if (passed) console.log(`# pass ${passed}`) | ||
@@ -159,0 +157,0 @@ if (failed) console.log(`# fail ${failed}`) |
{ | ||
"name": "tst", | ||
"description": "Tape-compatible test runner", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"repository": "dy/tst", | ||
@@ -6,0 +6,0 @@ "author": "Dmitry Yv", |
10526
266