Book Image

Jasmine JavaScript Testing Update

By : Paulo Vitor Zacharias Ragonha
Book Image

Jasmine JavaScript Testing Update

By: Paulo Vitor Zacharias Ragonha

Overview of this book

Table of Contents (15 chapters)

Chapter 6. Light Speed Unit Testing

In Chapter 4, Asynchronous Testing – AJAX, we saw how including AJAX testing in the application can increase the complexity of the tests. In the example in that chapter, we created a server where the results were predictable. It was basically a complex test fixture. Even though we could have used a real server implementation, it would increase the complexity of the test even more; try changing the state of a server with a database or third-party services from the browser—it is not an easy or scalable solution.

There is also the impact on productivity; these requests take time to process and transmit, which hurts the quick feedback loop that unit testing usually provides.

You can also say that these specs test both the client and the server code and, therefore, could not be considered unit tests; rather, they could be considered integration tests.

A solution to all these problems is to use either stubs or fakes in place of the real dependencies of the code...