Hello,
Was just writing some tests and wondered if it’s possible to provide a custom failure message when doing the BDD style of testing.
For example using the $assert syntax I can do this in my tests:
$assert.isEqual(12, mock.$callLog().startSubscription[1].months, “Should be 12 months”);
$assert.isEqual(12, mock.$callLog().startSubscription[1].fee, “Should have a fee of 12”);
$assert.isEqual(12, mock.$callLog().startSubscription[1].optionid, “Should be option id 12”);
With BDD (although I can use the asserts syntax above) the syntax is more like:
expect(mock.$callLog().startSubscription[1].months).toBe(12);
expect(mock.$callLog().startSubscription[1].fee).toBe(12);
expect(mock.$callLog().startSubscription[1].optionid).toBe(12);
The issue I have with using the ‘toBe’ style is that if any of the above asserts fail, the message I get is:
Expected [12] but received [11]
From that I don’t know which assert failed. I didn’t know if there was (or could be added) something like:
expect(mock.$callLog().startSubscription[1].months).toBe(12).onFail(“Should be 12 months”);
expect(mock.$callLog().startSubscription[1].fee).toBe(12).onFail(“Should have a fee of 12”);
expect(mock.$callLog().startSubscription[1].optionid).toBe(12).onFail(“Should be option id 12”);
Thanks!
John