Comparing version 0.0.4 to 0.0.5
@@ -75,3 +75,3 @@ #!/usr/bin/env node | ||
write(' Total: ' + total); | ||
write('\n Total: ' + total); | ||
let color = code ? kleur.red : kleur.green; | ||
@@ -78,0 +78,0 @@ write(color(' Passed: ' + done)); |
@@ -12,4 +12,4 @@ const diff = require('diff'); | ||
const LINE = num => kleur.dim('L' + num + ' '); | ||
const TAB = kleur.dim('→'), SPACE = kleur.dim('·'); | ||
const PRETTY = str => str.replace(/\{/g, 'Object {').replace(/\[/g, 'Array [').replace(/[ ]/g, SPACE).replace(/\t/g, TAB); | ||
const TAB=kleur.dim('→'), SPACE=kleur.dim('·'), NL=kleur.dim('↵'); | ||
const PRETTY = str => str.replace(/[ ]/g, SPACE).replace(/\t/g, TAB).replace(/(\r?\n)/g, NL); | ||
const PRINT = (sym, str, len) => colors[sym](sym + str + ' '.repeat(4 + len) + TITLE(sym == '++' ? '(Expected)\n' : '(Actual)\n')); | ||
@@ -19,3 +19,3 @@ | ||
let char = obj.removed ? '--' : obj.added ? '++' : '··'; | ||
let i=0, tmp, arr = obj.value.split('\n'); | ||
let i=0, tmp, arr = obj.value.replace(/\n$/, '').split('\n'); | ||
let out='', fmt = colors[char]; | ||
@@ -27,5 +27,6 @@ | ||
for (; i < arr.length; i++) { | ||
if (tmp = arr[i]) { | ||
tmp = arr[i]; | ||
if (tmp != null) { | ||
if (prev) out += LINE(prev + i); | ||
out += fmt(char + PRETTY(tmp)) + '\n'; | ||
out += fmt(char + PRETTY(tmp || '\n')) + '\n'; | ||
} | ||
@@ -32,0 +33,0 @@ } |
@@ -12,2 +12,4 @@ const kleur = require('kleur'); | ||
const IGNORE = /^\s*at.*(?:\(|\s)(?:node|(internal\/[\w/]*))/; | ||
const FAILURE = kleur.bold().bgRed(' FAIL '); | ||
const SUITE = kleur.bgWhite().bold; | ||
@@ -26,7 +28,7 @@ function stack(stack, idx) { | ||
function format(name, err) { | ||
function format(name, err, suite = '') { | ||
let details = err.details; | ||
let idx = err.stack && err.stack.indexOf('\n'); | ||
if (err.name.startsWith('AssertionError') && !err.operator.includes('not')) details = compare(err.actual, err.expected); // TODO? | ||
let str = ' ' + kleur.bold().bgRed(' FAIL ') + ' ' + QUOTE + kleur.red().bold(name) + QUOTE; | ||
let str = ' ' + FAILURE + (suite ? kleur.red(SUITE(` ${suite} `)) : '') + ' ' + QUOTE + kleur.red().bold(name) + QUOTE; | ||
str += '\n ' + err.message + kleur.italic().dim(` (${err.operator})`) + '\n'; | ||
@@ -46,3 +48,3 @@ if (details) str += GUTTER + details.split('\n').join(GUTTER); | ||
try { | ||
// console.log('(runner) name:', name); | ||
if (name) write(SUITE(kleur.black(` ${name} `)) + ' '); | ||
for (hook of before) await hook(); | ||
@@ -56,3 +58,3 @@ for (test of arr) { | ||
if (errors.length) errors += '\n'; | ||
errors += format(test.name, err); | ||
errors += format(test.name, err, name); | ||
write(FAIL); | ||
@@ -59,0 +61,0 @@ } |
{ | ||
"name": "uvu", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"module": "dist/index.mjs", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
27364
711