Skip to content

Instantly share code, notes, and snippets.

@jhines2k7
Created May 14, 2018 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhines2k7/f5da734dbcd06e08e90e891016c3871c to your computer and use it in GitHub Desktop.
Save jhines2k7/f5da734dbcd06e08e90e891016c3871c to your computer and use it in GitHub Desktop.
World's simplest JavaScript test runner
function assertEqual(a, b, desc) {
if (a === b) {
console.log(`${desc} ... PASS`);
} else {
console.log(`${desc} ... FAIL: ${a} != ${b}`)
}
}
function assertThrowsError(func, desc) {
try {
func();
console.log(`${desc} ... FAIL`);
} catch (e) {
console.log(`${desc} ... PASS`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment