mercredi 26 octobre 2016

Errors with .passThrough() using angular E2E

I am trying to test my real API using Angular MockE2E, but am getting errors using the .passThrough function.

Here is my code:

describe('simple test', function () {
var $controller, $httpBackend;

beforeEach(module('UCA-app'));
beforeEach(inject(function ($rootScope, _$controller_, _$httpBackend_, _SignupService_, _UserService_) {
        $controller = _$controller_;
        $httpBackend = _$httpBackend_;
        SignupService = _SignupService_;
        UserService = _UserService_;
        $scope = $rootScope.$new();
        $httpBackend.whenGET('http://localhost:2684/api/Account/GetPasswordPolicyMessage').passThrough();
}));

});

Which returns this error:

Error: Unexpected request: GET http://localhost:2684/api/Account/GetPasswordPolicyMessage

The method i am trying to test runs by default on the controller, but when i change the passthough to expect like so:

$httpBackend.expectGET('http://localhost:2684/api/Account/GetPasswordPolicyMessage').passThrough();

I get error:

TypeError: $httpBackend.expectGET(...).passThrough is not a function

Any ideas what i am doing wrong, or if i should be setting up differently for testing the actual API?

Aucun commentaire:

Enregistrer un commentaire