Testing Angular Applications exists to help developers better understand one of the trickier parts of using the power of Google’s Angular framework: writing testable, reliable code. Angular departs wildly from the earlier AngularJS framework, introducing developers to a slew of new concepts not familiar from AngularJS or any other JavaScript framework. Writing unit tests and end-to-end tests requires a deeper knowledge of Angular than even the most heroic of tutorials can convey. Angular written for production should be backed by a set of reliable and useful tests, and with this book, we equip the reader with the knowledge to deliver those tests.
Whether you’re an experienced developer contributing to an enterprise-scale Angular application or new to Angular and hoping to gain a deeper understanding of the framework, this book will help you understand the fundamentals of writing testable code. Angular is evolving at a rapid pace, faster than the official documentation can match. Supplemental material such as this book goes beyond the online documentation by providing step-by-step examples that explain not only the how but also the whys of unit testing in Angular. This book assumes a comfortable knowledge of JavaScript and some knowledge of TypeScript, a superset of JavaScript that adds a variety of new language features.
This book reflects many hours of real-world experience understanding and applying the Angular framework for both unit and end-to-end tests. As authors, we’ve read the online documentation, delved into the Angular source code, upgraded Angular multiple times (along with the example application written for this book), applied multiple Angular testing APIs, and created realistic examples covering each major system of Angular.
If you need to write testable Angular code and want to take advantage of our experience of having already walked the path, this book will help you on your testing journey.
The book has three parts that cover 11 chapters. Two appendixes include supplemental content:
Part 1 covers the most common concepts that you’ll need to understand to write unit tests for Angular:
beforeEach, afterEach, it, describe
, and matcher functions. You’ll also learn how to test classes.Part 2 covers how to write end-to-end tests with Protractor:
Part 3 is about continuous integration:
Appendix A covers setting up the sample project, and appendix B includes additional resources for you to consider.
In general, you can read the book from front to back, or you can pick and choose which chapters you want to read. Most chapters use the sample app, which you can install using appendix A, so you may want to get that set up before skipping around the book.
This book contains many examples of source code, both in numbered listings and inline with normal text. In both cases, this code is formatted in a fixed-width font like this
to separate it from ordinary text. Sometimes code is also in bold
to highlight when it has changed from previous steps in the chapter, such as when a new feature adds to an existing line of code.
In many cases, we’ve reformatted the original source code; we’ve added line breaks and reworked indentation to accommodate the available page space in the book. In rare cases, even this wasn’t enough, and listings include line-continuation markers (➥). Additionally, we’ve often removed comments in the source code from the listings when the code is described in the text, but code annotations accompany many of the listings to highlight important concepts.
You can find the accompanying code for the book on the book’s webpage at manning.com (www.manning.com/books/testing-angular-applications) and also on GitHub at http://mng.bz/z22f. To execute the code, you need to have Node.js version 6.9.0 or higher and npm version 3 or higher. You can use a Windows, Mac, or Linux machine. We wrote the code for this book on a Mac, so your experience may vary slightly. You can find installation instructions in appendix A.
Purchase of Testing Angular Applications includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum, go to https://forums.manning.com/forums/testing-angular-applications. You can also learn more about Manning's forums and the rules of conduct at https://forums.manning.com/forums/about.
Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the forum remains voluntary (and unpaid). We suggest you try asking the authors some challenging questions lest their interest stray! The forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.
18.119.132.223