angular.io icon indicating copy to clipboard operation
angular.io copied to clipboard

Document use of Mock http backend for testing

Open wolfgangmeyers opened this issue 10 years ago • 3 comments

Documentation should provide concrete examples of how to properly use the mock http backend in jasmine tests. I've found varying examples on the internet (like http://chariotsolutions.com/blog/post/testing-http-services-angular-2-jasmine/) but it would be nice to have an official example in the angular docs.

wolfgangmeyers avatar Sep 28 '16 22:09 wolfgangmeyers

This would be particularly helpful, since articles like this one, which clearly show what I'm needing to do, are obsolete: http://stackoverflow.com/questions/38526079/how-to-use-mockbackend-in-angular2

wolfgangmeyers avatar Sep 28 '16 22:09 wolfgangmeyers

This one seems more up to date: https://gist.github.com/wkwiatek/e8a4a9d92abc4739f04f5abddd3de8a7#file-app-3-http-spec-ts

wolfgangmeyers avatar Sep 28 '16 22:09 wolfgangmeyers

This is on our backlog and I hope to get to it soon. The testing doc sample includes a test that uses the MockBackend. We just haven't documented it yet.

See https://github.com/angular/angular.io/blob/master/public/docs/_examples/testing/ts/app/model/http-hero.service.spec.ts

wardbell avatar Dec 15 '16 17:12 wardbell