jeudi 23 juillet 2015

Jasmine spy expects to be called with "Object(...)"

I am completing a migration from Jasmine 1.3 to 2.0. So far I have refactored most of the code to comply with 2.0's newer syntax. However, a certain kind of tests are still failing.

In short, my test looks like this:

var obj = new CustomCriteria();

spyOn(my, "function");
my.function(obj);
expect(my.function).toHaveBeenCalledWith({ big: "fat object" });

my CustomCriteria class:

var CustomCriteria = function() {
    this.big = "fat object";
};

The test fails with the following:

Expected spy function to have been called with [ Object({ big: "fat object" }) ] but actual calls were [ ({ big: "fat object" }) ].

Note how the expectation has an "Object" wrapping around it, but the second does not. This test did not fail in < 2.0 of Jasmine, but is now failing after I update Jasmine. How can I fix this?

Aucun commentaire:

Enregistrer un commentaire