You have a real beef in that the documentation is not clear that ngMockE2E 
cannot 
be used on the client (i.e. karma/jasmine) side of an end-to-end testing 
setup. It is not unreasonable to interpret things like you have interpreted 
them, but it doesn't change the fact that the interpretation is wrong.

The ngMockE2E will pass through requests if instructed when used on the 
server side of an application rather than on the client side. This is meant 
so that you can still pass through certain requests that are hard to mock 
as pre-canned responses. What I mean by client and server-side is that in 
end-to-end testing there are two ends. You have the application to be 
tested which is served by a standard application server, and you have the 
test code that is driving the application usually executing in Karma or 
another test runner, which uses standard HTTP requests to communicate to 
the application which is executing in another process.

If you look at the documentation and how to setup ngMockE2E you will notice 
there is no mention of Jasmine, and the instructions are for how to set up 
in a real angular application:

myAppDev = angular.module('myAppDev', ['myApp', 'ngMockE2E']);
myAppDev.run(function($httpBackend) {
  phones = [{name: 'phone1'}, {name: 'phone2'}];

  // returns the current list of phones
  $httpBackend.whenGET('/phones').respond(phones);

  // adds a new phone to the phones array
  $httpBackend.whenPOST('/phones').respond(function(method, url, data) {
    phones.push(angular.fromJson(data));
  });
  $httpBackend.whenGET(/^\/templates\//).passThrough();
  //...});

As you can see in this example, they are mocking all the JSON data 
instructions, while letting it still fetch the templates from the server.

In order to use it from jasmine the setup would be quite different, using
angular.mock.module('ngMockE2E') and then setting up the 
$httpBackend.whenGET() in abeforeEach() rather than in a module.run().

As far as ngMidwayTester I linked you to, I believe this would, in fact, be 
compatible with ngMockE2E. Essentially ngMidwayTester replaces 
angular.mock.module() and inject() with it's own implementations. So you 
could use it like this:

beforeEach(function(){
  tester = ngMidwayTester('app', 'ngMockE2E');
  $http = tester.inject('$http');
  $httpBackend = tester.inject('$httpBackend');
  $rootScope = tester.inject('$rootScope');});

This should work, because you are no longer using the ngMock module (which 
always gets included when you use angular.mock.module()). Things should 
work exactly like you want them to usingngMidwayTester.

>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to