kingjs/assert-throws
@Throw an exception if a function fails to throw an exception.
Usage
Assert that a function throws an exception like this:
var assertThrows = require('@kingjs/assert-throws');
assertThrows(function() { });
throws:
"An assertion failed."
Provide a more descriptive error message like this:
var assertThrows = require('@kingjs/assert-throws');
assertThrows(
function() { },
"Expected an exception, but actually passed."
)
throws:
"Expected an exception, but actually passed."
API
declare function assertThrows(func: Function, message?: string);
Parameters
func
: Function expected to throw an exception.
message
: Message to throw iffunc
fails to throw an exception, else will throw "An assertion failed.".
Install
With npm installed, run
$ npm install @kingjs/assert-throws
License
MIT