title: Unittesting $http in AngularJS gives error "No method expectGet"
body: <p>I am having some issues to test $http in my AngularJS applications. I have tried to create the following example which fails for me:</p>
  
  <p>ControllerJS:</p>
  
  <pre><code>var testController = ['$scope', '$http', function($scope, $http) {
      $http.get('/test').success(function(data) {
        //TODO  
      });
  }];
  </code></pre>
  
  <p>ControllerTestJS:</p>
  
  <pre><code>describe("Test Controller", function () {
      var scope, httpMock;
      beforeEach(module('MailChimpApp'));
  
      beforeEach(inject(function ($injector, $rootScope) {
          httpMock = $injector.get('$httpBackend');
          scope = $rootScope.$new();
      }));
  
      afterEach(function () {
          httpMock.verifyNoOutstandingExpectation();
          httpMock.verifyNoOutstandingRequest();
      });
  
      it('testing post', function () {
          httpMock.expectGet('/test').respond([{ test: 'true' }]);
  
          var controller = scope.$new('testController');
  
          httpMock.flush();
      });
  });
  </code></pre>
  
  <p>When I run the test in Karma using Jasmin I get the following error:</p>
  
  <pre><code> TypeError: Object function $httpBackend(method, url, data, callback, headers) {
        var xhr = new MockXhr(),
            expectation = expectations[0],
            wasExpected = false;
  
        function prettyPrint(data) {
          return (angular.isString(data) || angular.isFunction(data) || data instanceof RegExp)
              ? data
              : angular.toJson(data);
        }
  
        if (expectation &amp;&amp; expectation.match(method, url)) {
          if (!expectation.matchData(data))
            throw Error('Expected ' + expectation + ' with different data\n' +
                'EXPECTED: ' + prettyPrint(expectation.data) + '\nGOT:      ' + data);
  
          if (!expectation.matchHeaders(headers))
            throw Error('Expected ' + expectation + ' with different headers\n' +
                'EXPECTED: ' + prettyPrint(expectation.headers) + '\nGOT:      ' +
                prettyPrint(headers));
  
          expectations.shift();
  
          if (expectation.response) {
            responses.push(function() {
              var response = expectation.response(method, url, data, headers);
              xhr.$$respHeaders = response[2];
              callback(response[0], response[1], xhr.getAllResponseHeaders());
            });
            return;
          }
          wasExpected = true;
        }
  
        var i = -1, definition;
        while ((definition = definitions[++i])) {
          if (definition.match(method, url, data, headers || {})) {
            if (definition.response) {
              // if $browser specified, we do auto flush all requests
              ($browser ? $browser.defer : responsesPush)(function() {
                var response = definition.response(method, url, data, headers);
                xhr.$$respHeaders = response[2];
                callback(response[0], response[1], xhr.getAllResponseHeaders());
              });
            } else if (definition.passThrough) {
              $delegate(method, url, data, callback, headers);
            } else throw Error('No response defined !');
            return;
          }
        }
        throw wasExpected ?
            Error('No response defined !') :
            Error('Unexpected request: ' + method + ' ' + url + '\n' +
                  (expectation ? 'Expected ' + expectation : 'No more request expected'));
      } has no method 'expectGet'
        at null.&lt;anonymous&gt;
  </code></pre>
  
  <p>The error occurs when I try to do httpMock.expectGET. I have remembered to include angular-mocks.js in my karma config, which looks like this:</p>
  
  <pre><code>JASMINE,
    JASMINE_ADAPTER,
    'Scripts/jquery-1.10.2.min.js',
    'Scripts/angular.js',
    'Scripts/angular-mocks.js',
    'Scripts/angular-resource.js',
    'Scripts/App.js',
    'Scripts/Controllers/*.js',
    'Unittests/JavaScript/Controllers/*.js'
  </code></pre>
  
  <p>Are there anything I might be missing to use $httpBackend to mock my $http-requests?</p>