Yes! If you use the Angular2 MockBackend module inside your unit tests, you can subscribe to the connections and check your headers inside. For instance:
var mockBackend = TestBed.get(MockBackend);
mockBackend.connections.subscribe((connection: MockConnection) => {
expect(connection.request.headers.get('Content-Type')).toEqual('application/json');
let options = new ResponseOptions({
body: JSON.stringify({ data: 'returned' })
});
connection.mockRespond(new Response(options));
});
source
share