I'm using Chai.js and chai-as-promised to test some of my promise-returning library functions. I was stuck testing exceptions thrown from such a function because it turns out that the expect()
function can also invoke a function rather than just examine the return value of a function and I was passing in the wrong thing.
See: https://stackoverflow.com/a/21587239/562139
(1) Is this documented somewhere? I couldn't find anywhere in the Chai.js documentation/page where it indicates that the expect API could take both values and functions that are executed before being tested/asserted upon.
(2) Where in the chai.js library source is the test for whether the argument to expect is a function, causing the function to be invoked before the tests?