how to mock http error for angular2 testing
<p>I am writing unit tests for an angular2 service. Code snippets:</p>

<pre><code>// jasmine specfile

// already injected MockConnection into Http

backend.connections.subscribe ((c: MockConnection) =&gt; {
    connection = c;
});

// doing get-request
myServiceCallwithHttpRequest ().subscribe (result =&gt; {
    // this test passes!
    expect (result).toEqual ({
        "message": "No Such Object"
    });
    // this test fails, don't know how to get the response code
    expect (whereIsResponseStatus).toBe (404);
});

connection.mockRespond (new Response (new ResponseOptions ({
    body: {
        "message": "No Such Object"
    },
    status: 404
})));
</code></pre>

<p>my Service:</p>

<pre><code>// service

myServiceCallwithHttpRequest (): Observable&lt;Response&gt; {
    return this.http.get ('/my/json-service').map (res =&gt; {
            // res.status == null
            return res.json ()
        })
        .catch (this.handleError); // from angular2 tutorial
}
</code></pre>

<p>The first expect is OK, the program goes into the map call, not the catch. But how do I get the status code 404? res.status is null.</p>