0%

Book Description

Testing Angular Applications teaches you how to make testing an essential part of your development and production processes. You'll start by setting up a simple unit testing system as you learn the fundamental practices. Then, you'll fine-tune it as you discover the best tests for Angular components, directives, pipes, services, and routing. Finally, you'll explore end-to-end testing, mastering the Protractor framework, and inserting Angular apps into your continuous integration pipeline.

Table of Contents

  1. Titlepage
  2. Copyright
  3. Dedication
  4. foreword
  5. preface
  6. acknowledgments
  7. about this book
    1. Who should read this book
    2. How this book is organized: a roadmap
    3. About the code
    4. Book forum
  8. about the authors
  9. about the cover illustration
  10. Chapter 1: Introduction to testing Angular applications
    1. 1.1 Angular testing overview
    2. 1.2 Getting friendly with TypeScript
    3. 1.3 A closer look at test types
      1. 1.3.1 Unit tests
      2. 1.3.2 E2E tests
      3. 1.3.3 Unit tests vs. E2E tests
    4. Summary
  11. part 1: Unit testing
    1. Chapter 2: Creating your first tests
      1. 2.1 Writing tests using Jasmine
        1. 2.1.1 Writing basic tests
      2. 2.2 Testing classes
        1. 2.2.1 Adding the rest of the tests
      3. Summary
    2. Chapter 3: Testing components
      1. 3.1 Basic component tests
      2. 3.2 Real-world component testing
        1. 3.2.1 Importing the dependencies
        2. 3.2.2 Setting up the tests
        3. 3.2.3 Adding the tests
      3. Summary
    3. Chapter 4: Testing directives
      1. 4.1 What are directives?
        1. 4.1.1 Components vs. directives
        2. 4.1.2 Different directives
      2. 4.2 Testing attribute directives
        1. 4.2.1 Introducing the favorite icon directive
        2. 4.2.2 Creating tests for FavoriteIconDirective
        3. 4.2.3 Setting up the FavoriteIconDirective test suite
        4. 4.2.4 Creating the FavoriteIconDirective tests
      3. 4.3 Testing structural directives
        1. 4.3.1 Introducing ShowContactsDirective
        2. 4.3.2 Creating your tests for ShowContactsDirective
        3. 4.3.3 Setting up the ShowContactsDirective test suite
        4. 4.3.4 Creating the ShowContactsDirective tests
      4. Summary
    4. Chapter 5: Testing pipes
      1. 5.1 Introducing PhoneNumberPipe
      2. 5.2 Testing PhoneNumberPipe
        1. 5.2.1 Testing the default usage for a pipe
        2. 5.2.2 Testing a pipe with a single parameter
        3. 5.2.3 Pipes with multiple parameters
      3. Summary
    5. Chapter 6: Testing services
      1. 6.1 What are services?
      2. 6.2 How do services work in Angular?
        1. 6.2.1 Dependency injection
        2. 6.2.2 The @Injectable class decorator
      3. 6.3 Creating services with Angular CLI
      4. 6.4 Testing PreferencesService
        1. 6.4.1 Testing for failures
      5. 6.5 Testing services with promises
        1. 6.5.1 How asynchronous changes testing
        2. 6.5.2 Testing for failures with asynchronous services
      6. 6.6 Testing HTTP services with observables
      7. Summary
    6. Chapter 7: Testing the router
      1. 7.1 What is the Angular router?
        1. 7.1.1 Configuring the router
        2. 7.1.2 Route guards: the router’s lifecycle hooks
      2. 7.2 Testing routed components
        1. 7.2.1 Testing router navigation with RouterTestingModule
        2. 7.2.2 Testing router parameters
      3. 7.3 Testing advanced routes
        1. 7.3.1 Route guards
        2. 7.3.2 Resolving data before loading a route
      4. Summary
    7. part 2: End-to-end testing
      1. Chapter 8: Getting started with Protractor
        1. 8.1 How Protractor works
        2. 8.2 Writing your first Protractor test
          1. 8.2.1 File structure
        3. 8.3 Installing and running
        4. 8.4 Interacting with elements
          1. 8.4.1 Test scenario: creating a new contact
          2. 8.4.2 Test scenario: workflows that don’t create a new contact
        5. 8.5 by and element methods
        6. 8.6 Interacting with a list of elements
          1. 8.6.1 Filtering web elements
          2. 8.6.2 Mapping the contact list to an array
          3. 8.6.3 Reduce
        7. 8.7 Page objects
        8. Summary
      2. Chapter 9: Understanding timeouts
        1. 9.1 Kinds of timeouts
        2. 9.2 Testing pages without Angular
          1. 9.2.1 Disabling waitForAngular
          2. 9.2.2 Automatically waiting for Angular
          3. 9.2.3 When to use browser.waitForAngularEnabled()
        3. 9.3 Waiting with ExpectedConditions
          1. 9.3.1 Waiting for the contact list to load
          2. 9.3.2 Testing a dialog
          3. 9.3.3 Waiting for elements to become stale
        4. 9.4 Creating custom conditions
          1. 9.4.1 Using browser.wait
          2. 9.4.2 Getting elements from the browser
        5. 9.5 Handling long-running tasks
          1. 9.5.1 Using expected conditions
          2. 9.5.2 The browser event loop
          3. 9.5.3 What happened to $timeout?
          4. 9.5.4 Highway to the Angular zone
          5. 9.5.5 Fixing the test
        6. Summary
      3. Chapter 10: Advanced Protractor topics
        1. 10.1 Configuration file in depth
          1. 10.1.1 Driver provider options
          2. 10.1.2 Desired capabilities
          3. 10.1.3 Plugins
          4. 10.1.4 Environment variables
        2. 10.2 Screenshot testing
          1. 10.2.1 Taking screenshots
          2. 10.2.2 Taking screenshots on test failure
          3. 10.2.3 Comparing screenshots
        3. 10.3 Experimental debugging features
          1. 10.3.1 WebDriver logs
          2. 10.3.2 Highlight delay
          3. 10.3.3 Blocking proxy
        4. 10.4 The control flow and debugging with Chrome DevTools
          1. 10.4.1 Asynchronous functions and promises
          2. 10.4.2 The WebDriver control flow
          3. 10.4.3 The future: async/await
          4. 10.4.4 Using Chrome DevTools
        5. Summary
    8. part 3: Continuous integration
      1. Chapter 11: Continuous integration
        1. 11.1 Jenkins
          1. 11.1.1 Setting up Jenkins
          2. 11.1.2 Unit tests
          3. 11.1.3 E2E tests
        2. 11.2 CircleCI
        3. Summary
    9. Appendix A: Setting up the sample project
      1. Introducing the Angular CLI
      2. Installing prerequisites
        1. Installing the Angular CLI the first time
        2. Updating an old version of the Angular CLI
      3. Installing the sample project
      4. Installing dependencies
      5. Running the application
    10. Appendix B: Additional resources
      1. Angular testing
      2. General testing
    11. Index
    12. Lists of Figures, Tables and Listings
3.235.249.219