Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
toBeFunction Jasmine Matcher
/*
Put on top of the file before describe statements
Usage:
expect(fn).toBeFunction()
*/
beforeEach(function (){
this.addMatchers({
toBeFunction: function (){
return Object.prototype.toString.call(this.actual)==='[object Function]';
}
});
});
@DataDaoDe

This comment has been minimized.

Copy link

@DataDaoDe DataDaoDe commented Feb 3, 2013

nice snippit!

@renra

This comment has been minimized.

Copy link

@renra renra commented Jan 27, 2017

Just wondering, why not simply typeof actual === 'function' ?

@customcommander

This comment has been minimized.

Copy link
Owner Author

@customcommander customcommander commented Aug 3, 2018

@renra Yeah I don't know what I was thinking when I wrote that. Should totally use typeof :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.