I am running my tests and noticed:
18 passing (150ms)
1 pending
I haven't seen this before. Previously test either passed, or failed. Timeouts caused failures. I can see which test is failing because it's also blue. But it has a timeout on it. Here's a simplified version:
test(`Errors when bad thing happens`), function(){
try {
var actual = doThing(option)
} catch (err) {
assert(err.message.includes('invalid'))
}
throw new Error(`Expected an error and didn't get one!`)
}
Thanks!
The test had a callback (ie, an actual function, not done) but refactoring the code solved the issue. The issue was how code that expects error should run:
test('Errors when bad thing happens', function() {
var gotExpectedError = false;
try {
var actual = doThing(option)
} catch (err) {
if ( err.message.includes('Invalid') ) {
gotExpectedError = true
}
}
if ( ! gotExpectedError ) {
throw new Error(`Expected an error and didn't get one!`)
}
});