How to mock Google Analytics function call ga()
<p>I have a service <em>MyService</em> with a function using the <code>ga()</code> event tracking call which I want to test: </p>

<pre><code>angular.module('myModule').factory('MyService', [function() {

    var myFunc = function() {
        ga('send', 'event', 'bla');
        // do some stuff
    }

    return {
        myFunc: myFunc
    }
]);
</code></pre>

<p>My spec file looks like this:</p>

<pre><code>describe('The MyService', function () {

    var MyService,
        ga;

    beforeEach(function () {
        module('myModule');
        ga = function() {};
    });

    beforeEach(inject(function (_MyService_) {
        MyService = _MyService_;
    }));

    it('should do some stuff', function () {
        MyService.myFunc();
        // testing function
    });
});
</code></pre>

<p>Running my tests always gives me:</p>

<blockquote>
  <p>ReferenceError: Can't find variable: ga</p>
</blockquote>