Angular TestDriven Development Second Edition

Md. Ziaul Haq

  • 出版商: Packt Publishing
  • 出版日期: 2017-02-08
  • 定價: $1,330
  • 售價: 6.0$798
  • 語言: 英文
  • 頁數: 252
  • 裝訂: Paperback
  • ISBN: 1786465477
  • ISBN-13: 9781786465474
  • 相關分類: Angular
  • 立即出貨 (庫存=1)

買這商品的人也買了...

商品描述

About This Book

  • Learn test-driven development (TDD) for JavaScript
  • Improve your Karma and Protractor expertise by setting up an Angular test suite
  • A wide range of testing techniques for professional Angular applications accompanied by practical examples

Who This Book Is For

This book is for developers who have experience with Angular but want to understand the wider context of when, why, and how to apply testing techniques and best practices to create quality clean code. To get the most out of this book, you should have a good understanding of HTML and JavaScript and a basic understanding of Angular.

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

In Detail

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.

Style and approach

This book is a complete guide to Angular unit testing techniques using Karma and performing end-to-end testing with Protractor.

商品描述(中文翻譯)

關於本書


  • 學習使用測試驅動開發(TDD)來開發 JavaScript

  • 透過建立 Angular 測試套件來提升 Karma 和 Protractor 的專業知識

  • 提供專業 Angular 應用程式的廣泛測試技巧,並附有實際範例

本書適合對象

本書適合已經具備 Angular 開發經驗,但想要了解何時、為何以及如何應用測試技巧和最佳實踐來創建高品質乾淨程式碼的開發人員。為了能夠充分利用本書,您應該對 HTML 和 JavaScript 有良好的理解,並且對 Angular 有基本的了解。

您將學到什麼


  • 瞭解 JavaScript 測試驅動開發(TDD)的概述,並簡要介紹測試技巧、工具和框架

  • 瞭解 Karma,並為 Angular 應用程式建立測試套件

  • 安裝和配置 Protractor 以用於 Angular,並探索一些重要的 Protractor API

  • 瞭解自動化測試,並使用 Karma 實現無界面自動化測試

  • 使用模擬物件、廣播事件和非同步行為實現測試技巧

  • 將基於 REST 的服務和 API 整合到應用程式中以提取資料

  • 使用 Travis CI 自動化 Karma 單元測試

詳細內容

本書是一本完整的指南,將向您展示如何使用 Karma 進行單元測試和使用 Protractor 進行端對端測試的測試技巧。它將向您展示如何使用 TDD 技巧優化 Angular 開發流程,並確保最終項目沒有錯誤。本書中的所有範例都基於 Angular v2,並與 Angular v4 兼容。

我們首先回顧 TDD 的生命週期,JavaScript 中的 TDD,以及各種 JavaScript 測試工具和框架。您將看到 Karma 和 Protractor 如何在執行 JavaScript 單元測試時簡化您的工作。我們將幫助您為 Angular 應用程式建立一個測試套件,並通過處理 REST API 資料來建立一個可測試的中大型 Angular 應用程式。

在建立基礎方面的基礎上,我們將繼續進行多個類別、部分視圖、位置引用、CSS 和 HTML 元素的測試。此外,我們還將探索如何使用 Karma 進行無界面瀏覽器測試。我們還將配置 Karma 檔案以自動化測試,並使用 TDD 處理 Angular 的元素(組件、服務、類別和廣播)。

最後,您將了解如何使用外部 API 提取資料,設置和配置 Protractor 以使用獨立的 Selenium 伺服器,以及設置 Travis CI 和 Karma 來測試您的應用程式。

風格和方法

本書是一本完整的指南,使用 Karma 進行 Angular 單元測試技巧,並使用 Protractor 進行端對端測試。