atecarlos/protractor-http-mock — pull request #9 by nielssj (2014-12-11 10:30:29+00:00)
Title: Support expectations/assetions about requests.

The way I see it a frontend has two input/output interfaces. First one being user triggered events and form-input on the DOM and the application's response in the form of modifications to the DOM. The second being HTTP requests/responses between the frontend and backend. Due to this I keep coming up with test cases that cannot be fully asserted without inspecting requests made to the backend.

I sketched out a working example of how this can be accomplished. I'm a newbie to the guts of Angular, so it's quite possible that there are better ways to publish and retrieve the list of requests from httpMock module.

I didn't include an example spec but since WebDriver.executeAsyncScript returns a promise your tests can basically do expectations like this:

expect(requestsMade()).toEqual([
{ url : 'http://localhost:2121/user', method : 'GET' }
]);

This is tested and works like a charm in my specs.