Justin
Justin

Reputation: 1438

Test my AngularJS service against a real web api

I am tasked with writing an AngularJS app that connects to a RESTful API provided by our client. I want to wrap that API in an angular service and write tests against it using the real API. I am confused on how and where to do this.

Should I be using Protractor for this test? It doesn't involve any UX elements at all, so it doesn't feel like it should use Protractor.

Should I be using Karma? I tried Karma with $httpBackend, ngMockE2E and .passThrough() for all whenGET and whenPOST calls, but I'm having issues with Unexpected request: POST errors.

Upvotes: 0

Views: 268

Answers (1)

Matthias
Matthias

Reputation: 15395

You should use Karma. Protractor is for testing interaction with web pages.

Your Unexpected request: POST errors should be resolvable if you use $httpBackend.expectPOST() for each POST request you issue.

Upvotes: 1

Related Questions