Jasmine allows you to write your own "matchers". The documentation explains it.
http://jasmine.github.io/2.0/custom_matcher.html
You could write a very specific matcher that is called
expect(obj).toHaveMethod("methodName");
Personally I would write something a bit more generic which checks the value type. That way I could use it to not just check if a method is defined on and object/instance, but anything that can store a value. It also gives me the possibility to check for types other then the function type.
expect(obj.methodName).toBeA(Function);
To get it to work you do have to make sure to add the toBeA "matcher".
beforeEach(function(){
jasmine.addMatchers({
toBeA: toBeA
});
});
function toBeA() {
return {
compare: function (value, type) {
var result = {pass: val != null && val.constructor === type || val instanceof type};
if (result.pass) {
result.message = 'Expected ' + value + ' to be a ' + type.name
} else {
result.message = 'Expected ' + value + ' to not be a ' + type.name
}
return result;
}
};
}