Problems mocking MockConnection error response
I'm testing http service in Angular2. I want to test the server, the server responds 'Unauthorized Error'. In test I used this code:
this.backend.connections.subscribe(
(connection: MockConnection) => {
console.log("Connection");
connection.mockError(<any>new Response(new ResponseOptions({status: 401, body: 'error'})));
}
);
In test I used handleError from angular.io..
It is the wrong decision. Tell me how to test this situation.
Hi,
So the problem is that MockConnection method to mock error response accepts an instance of Error which does not allow to pass response object to error handler. Cast to any allows to bypass type checks so we can finally pass the response, but to me it looks like a dirty hack.
Is this a bug in MockConnection API or do we do something wrong?
Thank you, Roman
+1 interested on this.
Anyone have a solution to this yet?
+1 ... bump
Could somebody add a minimal repro ? thanks
Thanks for reporting this issue. However, you didn't provide sufficient information for us to understand and reproduce the problem. Please check out our submission guidelines to understand why we can't act on issues that are lacking important information.
If the problem still persists, please file a new issue and ensure you provide all of the required information when filling out the issue template.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.