angularjs - TypeError: 'undefined' is not a function when using spyOn with Karma -


i've been using yeoman setup projects, , trying build angular module project apply feature toggles. i'm getting hung jasmine testing @ unit level, here 1 of tests:

var scope, rules; var elm; // load controller's module beforeeach(function() {   module('featuretoggle.directives', function($provide) {     $provide.decorator('rules', function($delegate) {       $delegate.resolvebyname = jasmine.createspy();        return $delegate;     });   });    inject(function(_rules_) {     rules = _rules_;   }); });  beforeeach(inject(function($rootscope, $compile) {   scope = $rootscope.$new();   elm = angular.element(     '<h1 feature-toggle feature-name="hello">' +     'hello world' +     '</h1>');    scope = $rootscope;   $compile(elm)(scope);   scope.$digest(); }));  it('should render content when feature enabled', function() {   jasmine.spyon(rules, 'resolvebyname').andreturn(false);    var contents = elm.find('h1');   expect(contents.eq(0)).tohaveclass('hidden'); }); 

i'm getting odd failure.

typeerror: 'undefined' not function (evaluating 'jasmine.spyon(rules, 'resolvebyname')') 

the karma.conf vanilla.

frameworks = ['jasmine'];  // list of files / patterns load in browser files = [    jasmine,    jasmine_adapter,    'app/components/angular/angular.js',    'app/components/angular-mocks/angular-mocks.js',    'src/*.js',    'src/**/*.js',    'test/mock/**/*.js',    'test/spec/**/*.js' ]; 

i'm using phantomjs , large, same issue exists (with different dialect of same error) in chrome.

using $log, nothing undefined. i'm rather lost.

change jasmine.spyon() spyon().

btw, not sure why spying same method twice.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -