Wrapping Up

We tackled some hard topics in this chapter. Dependencies can make testing very hard. You first learned to separate dependencies, where possible, and bring the function down to pure computations so it can be easily tested.

To deal with an intrinsic dependency, first decouple and inject the dependency into the code being tested. Then replace the dependency during test runs with a test double. You explored the use of spies, stubs, and mocks while writing automated tests for a problem with a dependency. Also you learned how to use Sinon and its benefits compared to handmade test doubles.

You will be applying the techniques learned in this chapter throughout the rest of the book and in your own projects. We have covered some of the most ...

Get Test-Driving JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.