I have an odd looking test spec below.
expect(function(){
expect(null).not.toEqualMoment(testContext.moment1);
}).toThrow();
The inner expectation fails because of the check below inside my custom matcher, which throws an exception.
if(!moment.isMoment(actual)) {
throw new Error(_.string.sprintf('Actual: %s , is not a Moment object.', jasmine.pp(actual)));
}
I think an exception has to be thrown here and not just return a failing result because if not, expect(null).not.toEqualMoment(null) will return true. ( If that makes sense to you ) .
So, If I fail custom matchers with exceptions, how can I test this?