I\'m getting the following error when running the entire suite of tests:
timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
It looks like ui-router leaks memory in unit tests. I added the following code in the run block of my application:
$rootScope.$on('$destroy', function() {
var clearAllMembers = function(obj, depth) { // prevent infinite recursion because of circular references
depth = depth || 0;
if (depth > 10) {
return;
}
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
if (typeof(obj[i]) == 'object') {
clearAllMembers(obj[i], ++depth);
}
if (obj) {
if (obj[i] && (obj[i] instanceof Array) && obj[i].length) {
obj[i].splice(0);
}
delete obj[i];
}
}
}
}
setTimeout(function() {
clearAllMembers($stateRegistry); // ui-router 1.0+
clearAllMembers($urlRouter);
clearAllMembers($urlService); // ui-router 1.0+
clearAllMembers($state);
});
});
and the memory consumption in unit tests is 7-8 times smaller (I have around 350 states).