Inject $log service on simple Jasmine test

angular-mock, angularjs, jasmine

Solution

How's this:

describe('basic test', function(){
    var log;
    beforeEach(inject(function(_$log_){
        log = _$log_;
    }));

    it('should just work', function(){
        log.info('it worked!');
        expect(log.info.logs).toContain(['it worked!']);
    });
});

Problem

Yes, I'm completely new to Angular and Jasmine, and I can't figure out how to inject a mock $log for my test. This is the test: ``` (function () { 'use strict'; describe('basic test', function(){ it('should just work', function(){ var $log; beforeEach(inject(function(_$log_){ $log = _$log_; })); $log.info('it worked!'); expect($log.info.logs).toContain(['it worked!']); }); }); }()) ``` This fails on the inject line with an error: ``` TypeError: Cannot set property 'typeName' of undefined ``` What am I missing?

Original source