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:<
Protractor does not yet support adding mock modules for Angular 2 applications:
// TODO: support mock modules in Angular2. For now, error if someone
// has tried to use one.
if (self.mockModules_.length > 1) {
deferred.reject('Trying to load mock modules on an Angular2 app ' +
'is not yet supported.');
}
And, I've also created a github issue for the TODO to draw attention:
This, by the way, also means that protractor-http-mock
is not gonna work since it relies on addMockModule
internally. I've personally tried protractor-http-mock
on a sample Angular2 application, got:
Failed: Trying to load mock modules on an Angular2 app is not yet supported.
Same is true for the http-backend-proxy and httpbackend packages.
I guess, while the issue is not yet fixed, you should consider firing up a proxy that would act as a sort of a "external mock" to your API backend, haven't done that personally, see more at: