Error in Jasmine test from Google Analytics in Angular app
<p>I'm working on some unit tests for my Angular app using Karma + Jasmine in a Grunt build. I have the following run block code that sets up Google Analytics:</p>

<pre><code>run.$inject = ['$rootScope', '$state', '$location', '$auth', '$window', 'AUTH_EVENTS', 'AuthService', 'Permission'];

function run($rootScope, $state, $location, $auth, $window, AUTH_EVENTS, AuthService, Permission) {
    // Initialize Google Analytics for tracking page views w/ ui-router state changes
    $window.ga('create', 'UA-XXXXXXXX-X', 'auto');
</code></pre>

<p>When running <code>grunt test</code> I'm getting the following error from the <code>$window.ga(..</code> line:</p>

<pre><code>TypeError: 'undefined' is not a function (evaluating '$window.ga('create', 'UA-XXXXXXX-X', 'auto')')
</code></pre>

<p>If I remove the line completely, the error is gone and the Jasmine tests continue on through just fine. Any ideas?</p>