<p dir="auto"><strong>I'm submitting a ...</strong>  (check one with "x")</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[x] bug report =&gt; search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request =&gt; Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question"><pre class="notranslate"><code class="notranslate">[x] bug report =&gt; search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request =&gt; Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
</code></pre></div>
<p dir="auto"><strong>Current behavior</strong><br>
<code class="notranslate">MockConnection</code> isn't consistent with a real connection in its error handling. The real connection checks the response status and if it is okay. If the status is within 200 and 299 then it calls next on the observable, otherwise error. <a href="https://github.com/angular/angular/blob/master/modules/%40angular/http/testing/mock_backend.ts#L63">MockRespond always calls next</a>. This means you have to explicitly check the status code in unit tests and call <a href="https://github.com/angular/angular/blob/master/modules/%40angular/http/testing/mock_backend.ts#L63">MockError</a></p>
<p dir="auto"><strong>Expected behavior</strong><br>
MockRespond would fire an error if the response status is not okay. Therefore, I cannot see much need for MockError except if one requires to test the error handling method without creating a mock HTTP method maybe.</p>
<p dir="auto"><strong>Minimal reproduction of the problem with instructions</strong><br>
Not sure this is 100% neccesary, will do if so. See <a href="http://stackoverflow.com/questions/41365022/angular-2-unit-testing-observable-errors-http?noredirect=1#comment69932655_41365022" rel="nofollow">this SO question</a> for more info.</p>
<p dir="auto"><strong>What is the motivation / use case for changing the behavior?</strong><br>
Better portrayal of a real HTTP connection in unit tests</p>
<p dir="auto"><strong>Please tell us about your environment:</strong><br>
Ubuntu 15.0, Webstorm, @angular/http version 2.4.1</p>
<ul dir="auto">
<li>
<p dir="auto"><strong>Angular version:</strong> 2.0.X<br>
2.4.1</p>
</li>
<li>
<p dir="auto"><strong>Browser:</strong><br>
all</p>
</li>
<li>
<p dir="auto"><strong>Language:</strong> [all | TypeScript X.X | ES6/7 | ES5]<br>
Typescript 2.1.4</p>
</li>
</ul>
<p dir="auto"><strong>I'm submitting a ...</strong>  (check one with "x")</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[ x] bug report =&gt; search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request =&gt; Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question"><pre class="notranslate"><code class="notranslate">[ x] bug report =&gt; search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request =&gt; Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
</code></pre></div>
<p dir="auto"><strong>Current behavior</strong><br>
Test Repo - <a href="https://github.com/mildfuzz/angular-mockError">https://github.com/mildfuzz/angular-mockError</a></p>
<p dir="auto">I am unable to test predicted HTTP error responses. Mockbackend can either send a response with an error code (which my app treats as a successful response in the test environment, but as an error in real world)</p>
<p dir="auto">I am unable to send status codes with an error response in my tests, so I can not test any error handling my application might implements.</p>
<p dir="auto"><strong>Expected behavior</strong><br>
at least one of the defined test cases passes</p>
<p dir="auto"><strong>Minimal reproduction of the problem with instructions</strong><br>
Test Repo - <a href="https://github.com/mildfuzz/angular-mockError">https://github.com/mildfuzz/angular-mockError</a></p>
<p dir="auto">this is a re-opening of issue <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="139123794" data-permission-text="Title is private" data-url="https://github.com/angular/angular/issues/7471" data-hovercard-type="issue" data-hovercard-url="/angular/angular/issues/7471/hovercard" href="https://github.com/angular/angular/issues/7471">#7471</a>, which was closed due to lack of repro steps.</p>
<p dir="auto"><strong>What is the motivation / use case for changing the behavior?</strong><br>
To be able to test all responses</p>
<p dir="auto"><strong>Please tell us about your environment:</strong><br>
OsX</p>
<ul dir="auto">
<li>
<p dir="auto"><strong>Angular version:</strong> 2.0.X<br>
Angular 2.1.0</p>
</li>
<li>
<p dir="auto"><strong>Browser:</strong> [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]<br>
Chrome 54</p>
</li>
<li>
<p dir="auto"><strong>Language:</strong> TypeScript 2.0.3</p>
</li>
<li>
<p dir="auto"><strong>Node (for AoT issues):</strong> <code class="notranslate">node --version</code> =   6.9.1</p>
</li>
</ul>