Comparing version 3.2.0 to 3.3.0
@@ -81,5 +81,8 @@ import fastDeepEqual from 'fast-deep-equal' | ||
equal as eq, | ||
equal as is, | ||
notEqual as neq, | ||
notEqual as isnt, | ||
notEqual as isNot, | ||
deepEqual as deq, | ||
throws as err | ||
} |
23
index.js
@@ -1,3 +0,5 @@ | ||
import * as assert from './assert.js' | ||
let assert = require('./assert.js') | ||
const isNode = typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]' | ||
function Test(o) { | ||
@@ -8,5 +10,3 @@ Object.assign(this, o) | ||
Test.prototype.run = async function run () { | ||
let from = this.startTime = performance.now() | ||
await this.fn(this) | ||
this.endTime = performance.now() - from | ||
} | ||
@@ -55,4 +55,2 @@ Object.assign(Test.prototype, { | ||
const isNode = typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]' | ||
export function log (ok, operator, msg, info = {}) { | ||
@@ -62,3 +60,3 @@ assertIndex += 1 | ||
current.assertion.push({ idx: assertIndex, msg }) | ||
console.log(`%c ✔ ${assertIndex} — ${msg}`, 'color: #229944') | ||
console.log(`${ isNode ? '' : '%c'}✔ ${assertIndex} — ${msg}`, 'color: #229944') | ||
passed += 1 | ||
@@ -73,3 +71,3 @@ } else { | ||
let ondone, hasOnly = false, running = false | ||
let ondone, only = 0, running = false | ||
@@ -82,3 +80,3 @@ | ||
Promise.resolve().then(() => { | ||
hasOnly = tests.some(test => test.only) | ||
tests.forEach(test => test.only && only++) | ||
@@ -94,3 +92,3 @@ dequeue() | ||
if (hasOnly && !test.only) { | ||
if (only && !test.only) { | ||
// in only-run - ignore tests | ||
@@ -102,3 +100,3 @@ skipped += 1 | ||
if (test.skip) { | ||
console.log(`%c# skip ${test.name}`, 'color: #ddd') | ||
console.log(`${isNode ? '' : '%c'}# skip ${test.name}`, 'color: #ddd') | ||
skipped += 1 | ||
@@ -126,5 +124,6 @@ return dequeue() | ||
// summarise | ||
console.log(`---`) | ||
const total = passed + failed + skipped | ||
console.log(`---\n# tests ${total}`) | ||
if (hasOnly) console.log(`# only ${total - skipped}`) | ||
if (only) console.log(`# only ${only} cases`) | ||
console.log(`# total ${ total }`) | ||
if (passed) console.log(`# pass ${passed}`) | ||
@@ -131,0 +130,0 @@ if (failed) console.log(`# fail ${failed}`) |
{ | ||
"name": "tst", | ||
"description": "Testing tool", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"repository": "dy/tst", | ||
@@ -6,0 +6,0 @@ "author": "Dmitry Yv", |
8638
213