Comparing version 1.1.0 to 2.0.0
19
index.js
@@ -8,9 +8,15 @@ 'use strict' | ||
const start = (msg) => process.stdout.write(`${msg}\n`) | ||
let startime | ||
const start = (msg) => { | ||
if (msg) process.stdout.write(`${msg}\n`) | ||
startime = Date.now() | ||
} | ||
const finish = () => { | ||
const sec = `${((Date.now() - startime) / 1000).toFixed(2)} seconds` | ||
const plural = run > 1 ? 'tests' : 'test' | ||
readline.clearLine(process.stdout, 0) | ||
readline.cursorTo(process.stdout, 0) | ||
process.stdout.write(`${colorGreen}All ${run} ${plural} passed${colorReset}\n`) | ||
const out = `${colorGreen}All ${run} ${plural} passed${colorReset} in ${sec}\n` | ||
process.stdout.write(out) | ||
} | ||
@@ -39,3 +45,9 @@ | ||
const runTests = async (cb, meta) => { | ||
const runTests = async (msg, cb, meta) => { | ||
if (typeof msg === 'function') { | ||
meta = cb | ||
cb = msg | ||
msg = undefined | ||
} | ||
start(msg) | ||
try { | ||
@@ -46,2 +58,3 @@ await cb() | ||
} | ||
finish() | ||
} | ||
@@ -48,0 +61,0 @@ |
{ | ||
"name": "mvt", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "A minimum viable testing framework, aka a few test helpers, 0 dependencies", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,3 +6,3 @@ # mvt [](https://npmjs.org/package/mvt) [](https://github.com/feross/standard) | ||
## why another testing module | ||
I'm getting tired of github security alerts on nested dev dependencies, usually | ||
I'm getting tired of Github security alerts on nested dev dependencies, typically | ||
from my chosen test framework. The tests I run are typically lite and | ||
@@ -33,13 +33,8 @@ don't require all the frills provided by the majors. I'm totes fine with | ||
**runTests** (testCallback[, meta]) - Just a wrapper that takes care to catch anything in it | ||
**runTests** (message, testCallback[, meta]) - Just a wrapper that takes care to catch anything in it | ||
- arguments | ||
- `string` - Message to display on test start-up | ||
- `function / async function` - Run your tests in this to ensure nothing is missed | ||
- `object` - If anything fails this object will be printed to stderr | ||
**start** (message) - Prints specified message on test start-up | ||
- arguments | ||
- `string` - Message to display on test start-up | ||
**finish** () - Prints "All X tests passed" in green, how fancy | ||
**test** (description, truthyOrComparison[[, comparison], meta]) - Test against single truthy value or compare two values | ||
@@ -65,5 +60,3 @@ - arguments | ||
runTests(async () => { | ||
start(`Testing my app`) | ||
runTests(`Testing my app`, async () => { | ||
test('Should be truthy', true) | ||
@@ -74,4 +67,2 @@ | ||
await testAsync('Should resolve truthy', async () => Promise.resolve(true)) | ||
finish() | ||
}) | ||
@@ -78,0 +69,0 @@ ``` |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
7045
82
76
1