Re: [jasmine-js] How to get additional info on matcher fail?

40 views
Skip to first unread message

Doug Reeder

unread,
Aug 3, 2012, 11:30:56 AM8/3/12
to jasmi...@googlegroups.com
There is no such mechanism in Jasmine at present, and IMNSHO that's a weakness.

You can do tricks like using .toEqual instead of .toBe to tell some expectations apart.

You can also write custom matchers like .toBeInstanceOf



-- Sent from my HP Pre 3



On Aug 3, 2012 10:35 AM, Vadim Milichev <vadim.m...@gmail.com> wrote:

Hi,
Anybody knows, if there a way to express something like this in Jasmine?

var destination = someCopyMethod(source);
for (var key in source)
expect(destination[key]).toBe(source[key]).because(key + " should be copied from source");

I saw this “because” in one of C# BDD frameworks and liked it for expressiveness and brevity. Want it in Jasmine! May be some extension?

Without it, if matcher fails, we have no clue what the key value was:

Error: Expected undefined to be defined.

Or such tests should be written in other way?

Thanks

--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/jasmine-js/-/2ESENArPFjUJ.
To post to this group, send email to jasmi...@googlegroups.com.
To unsubscribe from this group, send email to jasmine-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jasmine-js?hl=en.
Reply all
Reply to author
Forward
0 new messages