Additional tracing info in expect

8 views
Skip to first unread message

Thierry

unread,
Nov 19, 2010, 5:44:40 PM11/19/10
to Jasmine
Is there anyway to specify an additional string to be output when an
expect fails?

The reason I'm asking for this is that my spec has a loop and when
there is a failure it would be nice to output the index of where we
were in the loop to facilitate debugging. See example below for a
suggestion.

Thanks, Thierry.

it ( "should do something 1", function()
{
for ( var i=0; i<2; i++ )
expect ( var1 ).toEqual( "some1"+i ).traceWhenFail ( "Loop
index: " + i );
});

Christian Williams

unread,
Nov 19, 2010, 5:48:58 PM11/19/10
to jasmi...@googlegroups.com
I've long wanted to add something like this:

expect(1 + 2).toEqual(3).because("that's how math works");

but there's nothing like that now.

--X


--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
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.


Thierry Ciot

unread,
Nov 19, 2010, 5:58:11 PM11/19/10
to jasmi...@googlegroups.com
I'm not sure about "because".  On the first read of the example I liked it but after thinking a bit "because" kind of implies you would know the reason why it fails.

In any case, whether is called "because" or something else, it seems like it would be a useful feature to have.  I'm new to Jasmine but I have been developing in a TDD fashion for a while now and when a test fails you want as much info as possible. 

Thanks, Thierry.
Reply all
Reply to author
Forward
0 new messages