Testing AngularJS Cookbook

Testing AngularJS Cookbook

Testing Best Practices for AngularJS Developers

About the Book

The Testing AngularJS Cookbook makes testing AngularJS applications as simple as looking up a recipe. It has been designed to get newcomers to the AngularJS tool setup to speed on testing their applications. Whereas experienced developers already familiar with concepts such as Test Driven Development (TDD), can find practical testing patterns they can use to increase unit test writing productivity and maintainability. Note that the recipes in this book do not cover AngularJS 2.0, as the API will most likely change between now and when it becomes available.

The number of websites using AngularJS is growing rapidly. There is no doubt that AngularJS is a rising star in the front-end web development community. The toolset provides a solid foundation for building ambitious web applications that are maintainable and scale. Over 100,000 websites use AngularJS today, and every single one has people tasked with making sure it functions correctly. This book gives designers, developers, and testers instant recipes that empower building robust applications they can fearlessly refactor.

Who This Book Is For

This book assumes a basic understanding of the AngularJS toolset and some familiarity with the Jasmine and Protractor testing frameworks. If you are unaccustomed to working with these tools, have no fear. The first chapter in this book provides a high-level overview of all that AngularJS has to offer, and the second chapter covers the available testing frameworks.

Pedagogy of This Book

The first chapter covers a high-level overview of AngularJS. Chapter two reviews the available testing frameworks. All test examples are written in Jasmine as it is currently the most prevalent test framework used with AngularJS. After these introduction chapters, I dig right into unit testing the components of your AngularJS application, and finally cover end-to-end testing in the final chapter of this book. Each of the testing chapters is self-contained and do not build on the previous chapter. The recipes within them are listed alphabetically to help you find the solution you are looking for as quickly as possible.

Table of Contents

  • Chapter 1, AngularJS Essentials covers how the essentials of the AngularJS toolset, its guiding principles and its philosophy on structuring web applications.
  • Chapter 2, Frameworks for Testing gives a quick review of the available unit test and end-to-end testing frameworks.
  • Chapter 3, A/B/n Testing explains how you can optimize user experience with A/B/n tests.
  • Chapter 4, Constant Testing explores how to test constants in AngularJS, and why they are an important tool for working with third-party libraries.
  • Chapter 5, Controller Testing explains the best ways to unit test the business logic in your controllers.
  • Chapter 6, Directive Testing shows how to unit test the behavior of your directives.
  • Chapter 7, End-to-End Testing reveals how to create maintainable end-to-end tests that effectively validate page behavior from a user's point of view.
  • Chapter 8, Factory Testing highlights how AngularJS factories differ from services and how they can be unit tested.
  • Chapter 9, Filter Testing gives examples of unit testing filters.
  • Chapter 10, Module Testing describes the role of modules within AngularJS and how to unit test them.
  • Chapter 11, Performance Testing covers available tooling and how to use them to test the performance of your AngularJS application.
  • Chapter 12, Service Testing discusses unit testing the singleton services in your application.
  • Appendix A, Useful Tools highlights several useful open source projects and some recipes you can use when developing AngularJS applications with them.
  • Share this book

  • Categories

    • Agile
    • Management
    • Cookbooks
    • DIY
    • Self-Help
    • Software
    • Startups
    • Textbooks
  • Feedback

    Email the Author(s)

About the Author

Danny Lamb
Danny Lamb

Daniel Lamb is a talented senior software development professional with an extensive 15 years experience specializing in large-scale front-end architecture and web development in a fast-paced agile environment across multiple teams for millions of users.

Daniel's philosophy on front-end web development is to lead developer adoption in building web applications using JavaScript best practices and web standards markup. Leveraging unit test coverage to enable fearless refactoring and code reviews to maintain high quality.

Specialties include Front-end Development Architecture & Design Patterns, Advanced Object-Oriented JavaScript, Latency Optimization, Technical Leadership, Client-Side Technologies, and Cross-Browser Compatibility.

Follow him on GitHub and Twitter @daniellmb.

Causes Supported

Code Club

https://www.codeclub.org.uk

A nationwide network of volunteer-led after school coding clubs for children aged 9-11.

We create projects for our volunteers to teach at after school coding clubs or at non-school venues such as libraries. The projects we make teach children how to program by showing them how to make computer games, animations and websites. Our volunteers go to their local club for an hour a week and teach one project a week. Each term the students will progress and learn more whilst at the same time using their imaginations and making creative projects. Terms 1 & 2 use Scratch to teach the basics of programming. Term 3 teaches the basics of web development using HTML and CSS. Term 4 teaches Python and so on. We’d like to put a Code Club in every single primary school in the country. There are over 21,000 primary schools in the UK, it’s a big task but we think we can do it!

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub