Comparing version 0.3.4 to 0.3.5
@@ -9,5 +9,15 @@ # `tap-arc` Changelog | ||
## [0.3.5] - 2022-07-11 | ||
### Fixed | ||
- correctly describe failure then expected error message does not match actual thrown error. #29 | ||
### Changed | ||
- explicitly pin `strip-ansi` to v6.0.1 | ||
## [0.3.4] - 2022-03-30 | ||
## Changed | ||
### Changed | ||
@@ -14,0 +24,0 @@ - when total test count is 0, exit with code `1`. #26 |
111
index.js
@@ -9,15 +9,10 @@ #!/usr/bin/env node | ||
const { strict } = require('tcompare') | ||
const { | ||
blue, | ||
bold, | ||
dim, | ||
green, | ||
italic, | ||
red, | ||
underline, | ||
yellow, | ||
} = require('picocolors') | ||
const { blue, bold, dim, green, italic, red, underline, yellow } = require( | ||
'picocolors', | ||
) | ||
// Log test-group name | ||
const RESULT_COMMENTS = [ 'tests ', 'pass ', 'skip', 'todo', 'fail ', 'failed ', 'ok' ] | ||
const RESULT_COMMENTS = [ | ||
'tests ', 'pass ', 'skip', 'todo', 'fail ', 'failed ', 'ok', | ||
] | ||
@@ -34,7 +29,8 @@ const alias = { | ||
verbose: false, | ||
...minimist(process.argv.slice(2), { alias }) | ||
...minimist(process.argv.slice(2), { alias }), | ||
} | ||
if (options.help) { | ||
console.log(` | ||
console.log( | ||
` | ||
Usage: | ||
@@ -56,3 +52,4 @@ tap-arc <options> | ||
Output without ANSI escape sequences for colors | ||
example: tap-arc --no-color`) | ||
example: tap-arc --no-color`, | ||
) | ||
process.exit() | ||
@@ -91,12 +88,8 @@ } | ||
const compared = strict( | ||
lhs, | ||
rhs, | ||
{ | ||
includeEnumerable: true, | ||
includeGetters: true, | ||
pretty: true, | ||
sort: true | ||
} | ||
) | ||
const compared = strict(lhs, rhs, { | ||
includeEnumerable: true, | ||
includeGetters: true, | ||
pretty: true, | ||
sort: true, | ||
}) | ||
@@ -111,10 +104,14 @@ if (!compared.match) { | ||
if (char0 === '-') | ||
if (char0 === '-') { | ||
msg.push(red(line)) | ||
else if (char0 === '+') | ||
} | ||
else if (char0 === '+') { | ||
msg.push(green(line)) | ||
else if (char0 === '@') | ||
} | ||
else if (char0 === '@') { | ||
msg.push(italic(dim(line))) | ||
else | ||
} | ||
else { | ||
msg.push(line) | ||
} | ||
} | ||
@@ -149,13 +146,20 @@ } | ||
const justAnsi = stripped.length === 0 && extra.length > 0 | ||
if (!justAnsi) print(`${pad(2)}${extra}`) | ||
if (!justAnsi) { | ||
print(`${pad(2)}${extra}`) | ||
} | ||
}) | ||
parser.on('comment', (comment) => { | ||
if (!RESULT_COMMENTS.some((c) => comment.startsWith(c, 2))) | ||
if (!RESULT_COMMENTS.some((c) => comment.startsWith(c, 2))) { | ||
print(`\n${pad()}${underline(comment.trimEnd().replace(/^(# )/, ''))}\n`) | ||
} | ||
}) | ||
parser.on('todo', (todo) => { | ||
if (todo.ok) print(`${pad(2)}${yellow('TODO')} ${dim(todo.name)}\n`) | ||
else print(`${pad(2)}${red('TODO')} ${dim(todo.name)}\n`) | ||
if (todo.ok) { | ||
print(`${pad(2)}${yellow('TODO')} ${dim(todo.name)}\n`) | ||
} | ||
else { | ||
print(`${pad(2)}${red('TODO')} ${dim(todo.name)}\n`) | ||
} | ||
}) | ||
@@ -200,2 +204,16 @@ | ||
} | ||
else if ( | ||
operator === 'throws' && | ||
actual && | ||
actual !== 'undefined' && | ||
expected && | ||
expected !== 'undefined' | ||
) { | ||
// this combination is throws with expected/assertion | ||
msg.push( | ||
`Expected ${red(expected)} to match "${green( | ||
actual.message || actual, | ||
)}"`, | ||
) | ||
} | ||
else if (operator === 'throws' && actual && actual !== 'undefined') { | ||
@@ -233,3 +251,5 @@ // this combination is ~doesNotThrow | ||
if (at) msg.push(`${dim(`At: ${at.replace(cwd, '')}`)}`) | ||
if (at) { | ||
msg.push(`${dim(`At: ${at.replace(cwd, '')}`)}`) | ||
} | ||
@@ -268,7 +288,17 @@ if (options.verbose && stack) { | ||
print(`\n${pad()}total: ${result.count}\n`) | ||
if (result.pass > 0) print(green(`${pad()}passing: ${result.pass}\n`)) | ||
if (result.fail > 0) print(red(`${pad()}failing: ${result.fail}\n`)) | ||
if (result.skip > 0) print(`${pad()}skipped: ${result.skip}\n`) | ||
if (result.todo > 0) print(`${pad()}todo: ${result.todo}\n`) | ||
if (result.bailout) print(`${pad()}${bold(underline(red('BAILED!')))}\n`) | ||
if (result.pass > 0) { | ||
print(green(`${pad()}passing: ${result.pass}\n`)) | ||
} | ||
if (result.fail > 0) { | ||
print(red(`${pad()}failing: ${result.fail}\n`)) | ||
} | ||
if (result.skip > 0) { | ||
print(`${pad()}skipped: ${result.skip}\n`) | ||
} | ||
if (result.todo > 0) { | ||
print(`${pad()}todo: ${result.todo}\n`) | ||
} | ||
if (result.bailout) { | ||
print(`${pad()}${bold(underline(red('BAILED!')))}\n`) | ||
} | ||
@@ -280,2 +310,5 @@ tapArc.end(`${dim(`${pad()}${prettyMs(start)}`)}\n\n`) | ||
process.stdin.pipe(parser).pipe(tapArc).pipe(process.stdout) | ||
process.stdin | ||
.pipe(parser) | ||
.pipe(tapArc) | ||
.pipe(process.stdout) |
@@ -5,3 +5,3 @@ { | ||
"author": "tbeseda", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"license": "Apache-2.0", | ||
@@ -44,2 +44,3 @@ "main": "index.js", | ||
"tap-arc:simple": "npm run --silent tape:simple | ./index.js", | ||
"tap-arc:throws": "npm run --silent tape:throws | ./index.js", | ||
"tape:diff": "tape test/create-diff-tap.js", | ||
@@ -52,2 +53,3 @@ "tape:empty": "tape test/create-empty-tap.js", | ||
"tape:slow-pass": "tape test/create-slow-passing-tap.js", | ||
"tape:throws": "tape test/create-throws-tap.js", | ||
"test": "npm run lint:check && tape test/index.js | ./index.js" | ||
@@ -59,3 +61,3 @@ }, | ||
"picocolors": "^1.0.0", | ||
"strip-ansi": "^6.0.1", | ||
"strip-ansi": "6.0.1", | ||
"tap-parser": "^11.0.1", | ||
@@ -67,5 +69,5 @@ "tcompare": "^5.0.7", | ||
"@architect/eslint-config": "^2.0.1", | ||
"@types/node": "^17.0.23", | ||
"eslint": "^8.12.0", | ||
"tape": "5.5.2" | ||
"@types/node": "^18.0.03", | ||
"eslint": "^8.19.0", | ||
"tape": "5.5.3" | ||
}, | ||
@@ -72,0 +74,0 @@ "eslintConfig": { |
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
25497
263
Updatedstrip-ansi@6.0.1