javascript - jasmine spy on jquery -
i have jquery function:
$.fn.header = function (options) { return this.each(function () { // bla bla }); };
and somewhere in code call it:
function initheader() { // code before $('my-header').header({ }); }
and have jasmine test:
it('shows header in cases', function () { var header = spyon($.fn, 'header'); expect(header).tohavebeencalledwith('header'); });
when running test following error:
typeerror: 'undefined' not function (evaluating '$('my-header').header') @ initheader ..... header() method not exist
what problem , how can fix it?
p.s. have added jquery karma.conf.js file.
this doesn't jasmine error thrown code. seems not able find header method. check if js file $.fn.header definition included in karma config.
Comments
Post a Comment