Angular Test-Driven Development - Second Edition

Enhance your testing skills to build powerful and fault-free applications in Angular v4

Angular Test-Driven Development - Second Edition

Md. Ziaul Haq

1 customer reviews
Enhance your testing skills to build powerful and fault-free applications in Angular v4
Mapt Subscription
FREE
$29.99/m after trial
eBook
$22.40
RRP $31.99
Save 29%
Print + eBook
$39.99
RRP $39.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$22.40
$39.99
$29.99p/m after trial
RRP $31.99
RRP $39.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781786465474
Paperback252 pages

Book Description

This is a complete guide that shows you testing techniques with Karma that will help you perform unit testing and end-to-end testing with Protractor. It will show you how to optimize your Angular development process using TDD techniques and ensure your final project is free of bugs. All examples in this book are based on Angular v2 and are compatible with Angular v4.

We start by reviewing the TDD life cycle, TDD in the context of JavaScript, and various JavaScript test tools and frameworks. You will see how Karma and Protractor can make your life easier while running JavaScript unit tests. We will enable you to build a test suite for an Angular application and build a testable medium-to-large scale Angular application by handling REST API data.

Building on the initial foundational aspects, we move on to testing for multiple classes, partial views, location references, CSS, and the HTML element. In addition, we will explore how to use a headless browser with Karma. We will also configure a Karma file to automate the testing and tackle elements of Angular (components, services, classes, and broadcasting) using TDD.

Finally, you will find out how to pull data using an external API, set up and configure Protractor to use a standalone Selenium server, and set up Travis CI and Karma to test your application.

Table of Contents

Chapter 1: Introduction to Test-Driven Development
An overview of TDD
Practical TDD with JavaScript
Mechanism of testing
Self-test questions
Summary
Chapter 2: Details of JavaScript Testing
The craft of JavaScript testing
Types of testing
Testing tools and frameworks
The choice is ours
Say hello to Jasmine test suite
The Jasmine test suite for Angular
Self-test questions
Summary
Chapter 3: The Karma Way
The birth of Karma
Installing Karma
Configuring Karma
Testing with Karma
Confirming the Karma installation
Using Karma with Angular
Testing with Angular and Karma
Configuring Karma with Travis CI
Self-test questions
Summary
Chapter 4: End-to-End Testing with Protractor
An overview of Protractor
Origins of Protractor
Getting ready with Protractor
Integrating Protractor with Angular
Making the test better
Self-test questions
Summary
Chapter 5: Protractor, a Step Ahead
Advanced setup and configuration
Protractor APIs
Protractor tests - postmortem
Pausing and debugging
Self-test questions
Summary
Chapter 6: The First Step
Preparing the application's specifications
Setting up the Angular project
Top-down versus bottom-up approach - which one do we use?
Testing a component
Diving into our comment application
Onward and upward
Self-test questions
Summary
Chapter 7: Flip Flop
Fundamentals of TDD
Preparing an Angular project
Setting up headless browser testing for Karma
Walk-through of Angular routes and navigation
Searching the TDD way
Running the search wheel
Self-test questions
Summary
Chapter 8: Telling the World
Getting ready to communicate
Unit testing
Karma configuration
Testing routers and navigation
Recap of the application behavior
Updating the application behavior
Angular services
Communicating through the power of events
Planning further improvements
Moving ahead
Self-test questions
Summary

What You Will Learn

  • Get a clear overview of TDD in the context of JavaScript with a brief look at testing techniques, tools, and frameworks
  • Get an overview of Karma and create test suites for an Angular application
  • Install and configure Protractor for Angular and explore a few important Protractor APIs
  • Understand automated testing and implement headless automated tests with Karma
  • Implement testing techniques with mocks, broadcast events, and asynchronous behavior
  • Integrate REST-based services and APIs into an application to extract data
  • Automate Karma unit tests with Travis CI

Authors

Table of Contents

Chapter 1: Introduction to Test-Driven Development
An overview of TDD
Practical TDD with JavaScript
Mechanism of testing
Self-test questions
Summary
Chapter 2: Details of JavaScript Testing
The craft of JavaScript testing
Types of testing
Testing tools and frameworks
The choice is ours
Say hello to Jasmine test suite
The Jasmine test suite for Angular
Self-test questions
Summary
Chapter 3: The Karma Way
The birth of Karma
Installing Karma
Configuring Karma
Testing with Karma
Confirming the Karma installation
Using Karma with Angular
Testing with Angular and Karma
Configuring Karma with Travis CI
Self-test questions
Summary
Chapter 4: End-to-End Testing with Protractor
An overview of Protractor
Origins of Protractor
Getting ready with Protractor
Integrating Protractor with Angular
Making the test better
Self-test questions
Summary
Chapter 5: Protractor, a Step Ahead
Advanced setup and configuration
Protractor APIs
Protractor tests - postmortem
Pausing and debugging
Self-test questions
Summary
Chapter 6: The First Step
Preparing the application's specifications
Setting up the Angular project
Top-down versus bottom-up approach - which one do we use?
Testing a component
Diving into our comment application
Onward and upward
Self-test questions
Summary
Chapter 7: Flip Flop
Fundamentals of TDD
Preparing an Angular project
Setting up headless browser testing for Karma
Walk-through of Angular routes and navigation
Searching the TDD way
Running the search wheel
Self-test questions
Summary
Chapter 8: Telling the World
Getting ready to communicate
Unit testing
Karma configuration
Testing routers and navigation
Recap of the application behavior
Updating the application behavior
Angular services
Communicating through the power of events
Planning further improvements
Moving ahead
Self-test questions
Summary

Book Details

ISBN 139781786465474
Paperback252 pages
Read More
From 1 reviews

Read More Reviews

Recommended for You

Mastering Angular 2 Components Book Cover
Mastering Angular 2 Components
$ 35.99
$ 25.20
Angular 2 By Example Book Cover
Angular 2 By Example
$ 35.99
$ 25.20
Angular 2 Components Book Cover
Angular 2 Components
$ 23.99
$ 16.80
Mastering Web Application Development with AngularJS Book Cover
Mastering Web Application Development with AngularJS
$ 26.99
$ 5.40
Learning Angular 2 Book Cover
Learning Angular 2
$ 31.99
$ 22.40
Switching to Angular 2 Book Cover
Switching to Angular 2
$ 27.99
$ 19.60