Skip to content

Instantly share code, notes, and snippets.

@fhpriamo
Created October 7, 2020 17:13
Show Gist options
  • Save fhpriamo/a2831048aae714fc4bc4e136545c97d6 to your computer and use it in GitHub Desktop.
Save fhpriamo/a2831048aae714fc4bc4e136545c97d6 to your computer and use it in GitHub Desktop.
Ultra minimalistic testing utility for JS
const assert = require("assert");
function red(text) {
return `\x1b[30m\x1b[101m${text}\x1b[0m`;
}
function green(text) {
return `\x1b[30m\x1b[102m${text}\x1b[0m`;
}
function test(description, fn) {
try {
fn(assert);
console.log(green(' PASS '), description);
} catch (err) {
console.log(red(' FAIL '), description, '\n', err);
}
}
module.exports = test;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment