Book Image

JavaScript at Scale

By : Adam Boduch
Book Image

JavaScript at Scale

By: Adam Boduch

Overview of this book

Have you ever come up against an application that felt like it was built on sand? Maybe you've been tasked with creating an application that needs to last longer than a year before a complete re-write? If so, JavaScript at Scale is your missing documentation for maintaining scalable architectures. There's no prerequisite framework knowledge required for this book, however, most concepts presented throughout are adaptations of components found in frameworks such as Backbone, AngularJS, or Ember. All code examples are presented using ECMAScript 6 syntax, to make sure your applications are ready for next generation browsers.
Table of Contents (12 chapters)
11
Index

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...