Question

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?

Was it helpful?

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!']);
    });
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top