docs(mocks): add recipe for creating mocks with DI
I added a recipe for mocking classes with DI. Maybe I'm doing it wrong, so please give a good review before merging :).
Can you write it using https://github.com/angular/di.js/blob/master/example/testing/coffee.spec.js ?
I don't think creating mocks manually, is a scalable solution. Every time there is an update in the original class you might have to update your mocks also. I would rather prefer using Stubs. Use a library like - Sinon to stub your requests that are dependent on the XMLHttpRequest object. Any thoughts, where I could be wrong?
@tusharmath sinon actually provides quite a few mocks itself... mocks and stubs sort of solve different problems. Mocking a class which performs async ops is attractive for testing because it lets your tests have a bit more control, and the ability to run synchronously. Stubs are useful for letting you perform assertions at a certain point, or asserting that the particular subroutine was invoked the way you expect it to be.
Both are great for testing, but they don't solve the same problems
@caitp After seeing a lil bit here and there I finally got your point. Thanks!
Where would modules like - Mockery fit in? Are both of them solving the same problem?