Problems with random tests fail after upgrading to jasmine 2

1,028 views
Skip to first unread message

Henrik Gunnarsson

unread,
Apr 30, 2015, 10:47:11 AM4/30/15
to jasmi...@googlegroups.com
Hi guys

We currently use jasmine along with karma to run our frontend tests for angularjs in chrome

We are having some issues with our jasmine tests after we upgraded from jasmine 1.3 -> jasmine 2.2 (I have also tried 2.1 and 2.3). We have followed the upgrade guide and changed our code along with the syntax changes. 

The issue is that random tests seams to fail. It says in karma that one test is failing, but when you look at the reason it got nothing to do with that test. 

After much error searching and testing we have found a dirty fix by adding extra 'describe' or 'it'. It seams that jasmine does not like when it is certain number of those. One theory behind this is that there are some memory leaks that causes tests to fail. 

Any ideas or guidance what might be the cause of this?

Thank you,
Henrik ReQtest


Greg Cobb

unread,
Apr 30, 2015, 12:31:19 PM4/30/15
to jasmi...@googlegroups.com
Are you able to provide an example suite that has this behavior? Does that same problem happen in other browsers?

--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+...@googlegroups.com.
To post to this group, send email to jasmi...@googlegroups.com.
Visit this group at http://groups.google.com/group/jasmine-js.
For more options, visit https://groups.google.com/d/optout.

Henrik Gunnarsson

unread,
May 4, 2015, 10:34:34 AM5/4/15
to jasmi...@googlegroups.com
//
// Before

// Model
angular.module('AttachedFiles.Model.attachedFile', []);
attachedFile.factory("AttachedFile", function() {
var attachedFile = function() { // <-- anonymous function
};
return attachedFile;
});

// Test
it("should be a <instance>", function() {
var attachment = new AttachedFile();
log(attachment.constructor.name); // --> (empty string)
expect(attachment).toEqual(jasmine.any(AttachedFile));
});


//
// After
//

// Model
angular.module('AttachedFiles.Model.attachedFile', []);
attachedFile.factory("AttachedFile", function() {
var attachedFile = function AttachedFile() { // <-- named function "AttachedFile"
};
return attachedFile;
});

// Test
it("should be a <instance>", function() {
var attachment = new AttachedFile();
log(attachment.constructor.name); // --> AttachedFile
expect(attachment.constructor.name).toEqual("AttachedFile");
});

These are the tests that have been causing us all the problems with jasmine. 
Basically we wanted to check what the `class name` of the object was in order to make sure that the returned objects were of that instance.
This seemed to work in the old jasmine solution, but somehow broke our tests in the new solution.

Gregg Van Hove

unread,
May 11, 2015, 8:39:26 PM5/11/15
to jasmi...@googlegroups.com
Does the spec you showed work even with no other specs running, or does it fail by itself as well?

Usually, when I've seen errors like you mentioned in your initial message, it's because a spec that doesn't receive the `done` callback has some piece that is asynchronous and something in the async portion is failing and jasmine can only associate that failure with whichever spec is now running.

Hope this helps!

-Gregg

Reply all
Reply to author
Forward
0 new messages