0

I'm trying to unit test my project built on Angular with Karma-jasmine.

When I run the test I get this error:

Error: Unexpected request: GET assets/l10n/en.js

This is my spec file:

describe('test Overview Factory', function() {
  var overviewFactory, api_url, $q, httpBackend, $scope, response;

  beforeEach(angular.mock.module('app'));

  beforeEach(inject(function(_OverviewFactory_, _$q_, _$httpBackend_, _$rootScope_, API_URL) {
    $q = _$q_;
    api_url = API_URL;
    overviewFactory = _OverviewFactory_;
    httpBackend = _$httpBackend_;
    $scope = _$rootScope_.$new();
    httpBackend.whenGET('url', undefined, {
      Authorization: "Bearer token"
    }).respond();

  }));

  // Verify our factory exists
  it('should be defined', function() {
    expect(overviewFactory).toBeDefined();
  });

  it('should gets totals from api', function() {
    httpBackend.expectGET('url').respond(200);

    httpBackend.flush();
  });
});

If I delete the line httpBackend.flush(); it works properly. What am i doing wrong?

Massi Issar
  • 403
  • 5
  • 23
  • check out this http://stackoverflow.com/questions/18147606/why-do-i-receive-error-unexpected-request-get-internalapi-quotes – Carlos Laspina Nov 14 '16 at 13:26
  • @CarlosLaspina i already checked it, it seems that's not the same issue. I think my issue comes from angular-translate module. – Massi Issar Nov 14 '16 at 16:14

0 Answers0