question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems mocking MockConnection error response

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

20reactions
leovrfcommented, Mar 15, 2016

+1 interested on this.

1reaction
cbomkampcommented, May 23, 2016

Anyone have a solution to this yet?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found