javascript - Why are my tests failing and console.log() statements within a lodash method not logging? -


i have failing tests breaking @ various lodash methods work fine in browser. while trying debug threw in console.log()s within callback argument see what's going on, not showing in tests. same code run in browser both works fine , writes console. suspect breaking functionality related missing log statements.

this angular app in i'm supplying lodash service.

app

app.value('_', window._);  app.service('myservice', function(_) {   return {     filternulls: function(obj) {       // logs correctly everywhere       console.log(obj);        return _.omit(obj, function(val, key) {         // logs in browsers not in jasmine/karma environment         console.log('test');         return val === null;       });     }       }; }); 

tests

describe('myservice', function() {   beforeeach(function() {     module(function($provide) {       $provide.value('_', window._);     });   });    it('should strip nulls', inject(function(myservice) {     // fails because null value not removed     expect(myservice.filternulls({          key: 'key1',          someprop: 'bar',          someotherprop: null        }))       .toequal({          key: 'key1',          someprop: 'bar'       });   }); }); 

i'm not sure of why logs aren't showing when karma runs - me when test code. there may problem not obvious or me.

i can usage of _.omit incorrect. the docs:

the callback bound thisarg , invoked 3 arguments; (value, key, object).

meanwhile, callback parameters this:

function(key, val) { .. } 

this minor adjustment makes test pass me:

function(val) { .. } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -