javascript - Missing functions in Karma tests -


i'm using jasmine, karma, , phantomjs automate tests, i'm hitting problem: phantom doesn't seem parse js correctly. example, i'm using mock:

var app = function() {   return {     pagecontroller : {       currentpage : {         on : function() {},         tojson : function() {},         : function() {           return dark;         }       }     },     mainlayout : {       header : {         show : function() {},         $el : {}       }     }   }; };  console.log("in test", app()); 

...which logs out as:

phantomjs 1.9 (mac) log: [ 'in test',   { pagecontroller: {},     mainlayout: { header: [object] } } ] 

app.pagecontroller has been emptied here, causes tests fail. why happening & how can fix it?

the problem seems directly related function definitions. example:

console.log("this function:", function() { return 'wat'; }); 

yields

phantomjs 1.9 (mac) log: [ 'this function:', null ] 

the error occurs in chrome. squashes created jasmine spies well, i'm guessing it's karma?

karma's logging reports functions null. (tests failing unrelated reasons).


Comments