1.0.6 • Published 6 years ago

@kingjs/assert-throws v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

@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 if func fails to throw an exception, else will throw "An assertion failed.".

Install

With npm installed, run

$ npm install @kingjs/assert-throws

License

MIT

Analytics

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago