(Note: I've also posed this question on stackoverflow here:http://stackoverflow.com/questions/14464621/qunit-equal-very-slow-when-reporting-complex-object)
I've found that QUnit can be very slow when generating a failure report when an equal assertion fails and the expected value is a complicated object. Is this a known issue? Is there any way to limit the depth QUnit recurses into the "expected" object while generating its failure report? In the meantime I'm thinking of switching to using ok, but would much rather use equal if I can somehow make the perf better.
Here's a sample test with the associated call stack that I'm seeing. This is causing IE9 and even Chrome to completely hang:
UT code:
var expectedObject = {complicated object};
equal(objectToTest, expectedObject, 'Verify that the expected object was found.');
Call stack when assertion fails (hit break in debugger when browser appears to hang...sorry for the poor formatting, but pretend each word separated by a space is a new line/stack frame): typeOf parse array parse object parse object parse object parse object parse object parse object parse object parse array parse object parse object parse array parse object parse object parse array parse object parse push equal
Here are the internals of QUnit's parse (I'm not seeing an obvious way to make it stop recursing OOB but I might've overlooked it):
jsDump = { parse: function( obj, type, stack ) { //type is used mostly internally, you can fix a (custom)type in advance stack = stack || [ ]; var inStack, res, parser = this.parsers[ type || this.typeOf(obj) ]; type = typeof parser; inStack = inArray( obj, stack ); if ( inStack != -1 ) { return "recursion(" + (inStack - stack.length) + ")"; } //else if ( type == "function" ) { stack.push( obj ); res = parser.call( this, obj, stack ); stack.pop(); return res; } // else return ( type == "string" ) ? parser : this.parsers.error; },