Add 'throws'/'notThrows' assertion to Ospec for error reporting (#2255)

* Ospec: added assertion that function does/doesnt throw error

* Ospec.throws passes npm test

* Ospec.throws: Address requested changes

* Ospec: message comparison support for .throws/.notthrows

Credit to @maranomynet, #2227
This commit is contained in:
Robin (Robert) Thomas 2018-11-21 14:46:34 -06:00 committed by Isiah Meadows
parent 22427db882
commit 0fd1bc9cae
4 changed files with 40 additions and 1 deletions

View file

@ -429,7 +429,7 @@ If an argument is defined for the `assertions` function, the test is deemed to b
### Assertion o(any value)
Starts an assertion. There are four types of assertion: `equals`, `notEquals`, `deepEquals` and `notDeepEquals`.
Starts an assertion. There are six types of assertion: `equals`, `notEquals`, `deepEquals`, `notDeepEquals`, `throws`, `notThrows`.
Assertions have this form:
@ -467,6 +467,22 @@ Asserts that two values are recursively equal
Asserts that two values are not recursively equal
#### Function(String description) o(Function fn).throws(Object constructor)
Asserts that a function throws an instance of the provided constructo
#### Function(String description) o(Function fn).throws(String message)
Asserts that a function throws an Error with the provided message
#### Function(String description) o(Function fn).notThrows(Object constructor)
Asserts that a function does not throw an instance of the provided constructor
#### Function(String description) o(Function fn).notThrows(String message)
Asserts that a function does not throw an Error with the provided message
---
### void o.before(Function([Function done [, Function timeout]]) setup)