Protractor, mocking backend with angular2 on api request
<p>I could use some help to find a solution for my problem. I need to mock some data to my angular2 application when it makes a request to an api, I need to do something like:</p>

<pre><code>$httpBackend.when('GET', '/userbookings/').respond(my json file data);
</code></pre>

<p>The problem is that all I can find on google, using the $httpBackend which is used for angularJS (angular 1).</p>

<p>Does any know how I can get this to work in my E2E test (The application is an angular2 applciation)? I'm trying to do this with both protractor or nightwatch (Have tried both frameworks)</p>

<p><strong>Spec test:</strong></p>

<pre><code>describe('Protractor Mocking bookings for angular2 site', function() {

var ngMockE2E = require('ng-mock-e2e');

var $httpBackend = ngMockE2E.$httpBackend;

beforeEach(function() {
    ngMockE2E.addMockModule();
    ngMockE2E.addAsDependencyForModule('myApp');
    ngMockE2E.embedScript('/bower_components/angular-mocks/angular-mocks.js');
});


afterEach(function() {
    ngMockE2E.clearMockModules();
});

it('Inject mock data of bookings', function() {

    var EC = protractor.ExpectedConditions;
    var global = require('../bin/globals.js');

    // Bookings data in a json file which should be send as the response
    var mockData = require('../testData.json');

    browser.ignoreSynchronization = false;

    $httpBackend.when('GET', '/userbookings').respond(mockData);

    browser.get(global.so.enLoggedIn);

});

});
</code></pre>

<p>This test wont work because it's using some angular1 way. Have showed it, so you can see how my test looks like.</p>

<p>Hope someone can help me out here, cause its really hard to find some working with angular2.</p>