Problems mocking MockConnection error response
See original GitHub issueI’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.
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Problems mocking MockConnection error response #12857
I am unable to send status codes with an error response in my tests, so I can not test any error handling my...
Read more >Mock connection problems/errors/exceptions - Stack Overflow
In response I want connection exception was thrown(for example javax.net.ssl.SSLException ) just like java app would throw. I know how to throw ...
Read more >Mocking error responses - Recipes - Mock Service Worker Docs
When it comes to mocking an error response, it's recommended to compose a valid response using res() composition chain, rather than throwing ...
Read more >unittest.mock — getting started — Python 3.11.1 documentation
One problem with over use of mocking is that it couples your tests to the implementation of your mocks rather than your real...
Read more >Using VCR to mock connection refused + timeout errors
Hi all,. With webmock, I'm aware you can do something like this: stub_request(:any, 'www.example.net').to_raise(StandardError.new("some
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

+1 interested on this.
Anyone have a solution to this yet?