Skip to content

Instantly share code, notes, and snippets.

@joelmccracken
Created October 25, 2018 19:30
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 joelmccracken/247a8e5218c2b7d43192b46352c55755 to your computer and use it in GitHub Desktop.
Save joelmccracken/247a8e5218c2b7d43192b46352c55755 to your computer and use it in GitHub Desktop.
function assertThrows(triggeringFn, testFn) {
var sawError = false;
try {
triggeringFn();
} catch (Exception e) {
sawError = true;
assert(testFn(e), "Exception did not pass test!");
}
assert(sawError, "Error was not thrown!");
}
assertThrows(foo, (e)=> e.statusCode == STATUS_CODE_NOT_FOUND)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment