One idea I have is to develop a custom matcher using Jasmine 2.0 to validate spies based on additional criteria. To put it in simple terms, something along the lines of:
var customMatchers = {
toDoSomething: function(util, customEqualityTesters) {
return {
compare: function(spy) {
var comparison = {};
comparison.pass = testSomeCondition(spy);
if (!comparison.pass) {
comparison.message = "Anticipate " + /insert code here/ + " to perform an action";
}
return comparison;
}
}
}
};
beforeEach(function() {
jasmine.addMatchers(customMatchers);
});
My query revolves around retrieving the spy name, which is provided as the first argument in the factory method: createSpy(name, originalFn)
.
I've scoured through both the Jasmine v2.6 documentation and various online guides but haven't found any information on this topic.
console.log(spy)
shows function(...) {...}