Book Image

JavaScript at Scale

By : Adam Boduch
Book Image

JavaScript at Scale

By: Adam Boduch

Overview of this book

Table of Contents (17 chapters)
JavaScript at Scale
About the Author
About the Reviewers

Testing mock scenarios

The more our application scales, the more scenarios it'll have to deal with. This is the result of more users using more features, and all the ensuing complexity our code has to handle. Having mock data and unit tests can really help put these scenarios to the test. In this section, we'll go over some of the options available to us for creating these mock scenarios and then testing them, both with our unit tests and by interacting with the system as a user.

Mock APIs and test fixtures

Mock data is valuable to us for many reasons, one of which is unit tests. If we're mocking the API, we can run our unit tests as though our code is hitting a real API. We have fine-grained control over individual data points in our mock data, and we're free to change it how we see fit—it's sandboxed data, it has no negative effect on the outside world. Even if we're generating our mock data using a tool, we can get in there and shuffle things about.

Some unit testing tools accept fixtures...