0

I have AngularJS + RequireJS app. My task is to create a backendless version for UI development purposes. So a version where some/all HTTP requested are mocked. The desired user flow is:

  1. User goes to /debug to initialise a backendless version.
  2. User can use the app with HTTP requests being mocked.

I'm trying to use ngMockE2E.$httpBackend. But I can't find any information on how to inject it into already bootstrapped app. Following most of googled examples I'm trying to create a new module and bootstrap that one:

(function(ng, mod, _, $, undefined){
    'use strict';

    mod.run(function($httpBackend) {

    })
}(angular, angular.module('rexBackendless', ['rex', 'ngMockE2E']), _, jQuery));

angular.bootstrap(document, ["rexBackendless"]);

But this gives me "Error: ng:btstrpd App Already Bootstrapped with this Element". Any ideas on how to develop this task?

Tomasz Jureczko
  • 167
  • 3
  • 10

1 Answers1

0

Drop the call to bootstrap():

var app = angular.module('rexBackendless', ['rex', 'ngMockE2E']);

app.run(function($httpBackend) {
    $httpBackend.whenGET('yo').respond('wat');
    // ...
});
Eliran Malka
  • 15,821
  • 6
  • 77
  • 100