Cover image for AngularJS Test-driven Development.
AngularJS Test-driven Development.
Title:
AngularJS Test-driven Development.
Author:
Chaplin, Tim.
ISBN:
9781784393823
Personal Author:
Physical Description:
1 online resource (238 pages)
Contents:
AngularJS Test-driven Development -- Table of Contents -- AngularJS Test-driven Development -- Credits -- About the Author -- About the Reviewers -- www.PacktPub.com -- Support files, eBooks, discount offers, and more -- Why subscribe? -- Free access for Packt account holders -- Preface -- What this book covers -- Who this book is for -- Conventions -- Reader feedback -- Customer support -- Downloading the example code -- Errata -- Piracy -- Questions -- 1. Introduction to Test-driven Development -- An overview of TDD -- Fundamentals of TDD -- Measuring success -- Breaking down the steps -- Measure twice cut once -- Diving in -- Setting up the test -- Creating a development to-do list -- Test first -- Making it run -- Making it better -- Testing techniques -- Testing with a framework -- Testing doubles with Jasmine spies -- Stubbing a return value -- Testing arguments -- Refactoring -- Building with a builder -- Self-test questions -- Summary -- 2. The Karma Way -- JavaScript testing tools -- Karma -- Protractor -- JavaScript testing frameworks -- Jasmine -- Selenium -- Mocha -- Birth of Karma -- The Karma difference -- Importance of combining Karma with AngularJS -- Installing Karma -- Installation prerequisites -- Configuring Karma -- Customizing Karma's configuration -- Confirming Karma's installation and configuration -- Common installation/configuration issues -- Testing with Karma -- Confirming the Karma installation -- Using Karma with AngularJS -- Getting AngularJS -- Bower -- Bower installation -- Installing AngularJS -- Installing Angular mocks -- Initializing Karma -- Testing with AngularJS and Karma -- A development to-do list -- Testing a list of items -- Test first -- Assemble, Act, and Assert (3 A's) -- Make it run -- Make it better -- Adding a function to the controller -- Test first -- Assemble, Act, and Assert (3 A's).

Make it run -- Make it better -- Self-test questions -- Summary -- 3. End-to-end Testing with Protractor -- An overview of Protractor -- Origins of Protractor -- End of life -- The birth of Protractor -- Life without Protractor -- Protractor installation -- Installation prerequisites -- Installing Protractor -- Installing WebDriver for Chrome -- Customizing configuration -- Confirming installation and configuration -- Common installation/configuration issues -- Hello Protractor -- TDD end-to-end -- The pre-setup -- The setup -- Test first -- Installing the test web server -- Configuring Protractor -- Getting down to business -- Specification -- The development to-do list -- Test first -- Assemble, Act, Assert (3 A's) -- Running the test -- Make it run -- Make it better -- Cleaning up the gaps -- Async magic -- Loading a page before test execution -- Assertion on elements that get loaded in promises -- TDD with Protractor -- Self-test questions -- Summary -- 4. The First Step -- Preparing the application's specification -- Setting up the project -- Setting up the directory -- Setting up Protractor -- Setting up Karma -- Setting up http-server -- Top-down or bottom-up approach -- Testing a controller -- A simple controller test setup -- Initializing the scope -- Bring on the comments -- Test first -- Assemble -- Act -- Assert -- Make it run -- Adding the module -- Adding the input -- Controller -- Make it pass -- Make it better -- Implementing the Submit button -- Configuring Karma -- Test first -- Assemble -- Act -- Assert -- Make it run -- Make it better -- Back up the test chain -- Bind the input -- Onwards and upwards -- Test first -- Assemble -- Act -- Assert -- Make it run -- Fixing the unit tests -- Make it better -- Coupling of the test -- Self-test questions -- Summary -- 5. Flip Flop -- Fundamentals -- Protractor locators -- CSS locators.

Button and link locators -- Angular locators -- URL location references -- Creating a new project -- Setting up headless browser testing for Karma -- Preconfiguration -- Configuration -- Walk-through of Angular routes -- Setting up AngularJS routes -- Defining directions -- Configuring ngRoute -- Defining the route controllers -- Defining the route views -- Assembling the flip flop test -- Making the views flip -- Asserting a flip -- Making flip flop run -- Making flip flop better -- Searching the TDD way -- Deciding on the approach -- Walk-through of search query -- The search query test -- The search query HTML page -- The search application -- Show me some results! -- Creating the search result routes -- Testing the search results -- Assembling the search result test -- Selecting a search result -- Confirming a search result -- Making the search result test run -- Creating a location-aware test -- Making the search result better -- Confirming the route ID -- Setting up the route ID unit test -- Confirming the ID -- Making the route parameter's test run -- Self-test questions -- Summary -- 6. Telling the World -- Before the plunge -- Karma configuration -- File watching -- Using a bottom-up approach -- Services -- Publishing and subscribing messages -- Emitting -- Testing emit -- Testing broadcast -- Testing broadcast -- Publishing and subscribing - the good and bad -- The good -- Communicating through events -- Reducing coupling -- Harnessing the power of events -- The plan -- Rebranding -- Seeing recently viewed items -- Test first -- Assembling SearchController -- Selecting a product -- Expecting events to be published -- Making the search controller run -- Recently viewed unit test -- Test first -- Assembling RecentlyViewedController -- Invoking a recently viewed item -- Confirming RecentlyViewedController -- Making RecentlyViewedController run.

End-to-end testing -- Test first -- Assembling the recently viewed end-to-end test -- Selecting a search result -- Confirming recently viewed items -- Making the recentlyViewedItems test pass -- Making recently viewed items better -- Creating a product cart -- Publisher test first -- Assembling searchDetailController -- Invoking the saving of a product -- Confirming the save event -- Making the saveProduct test pass -- Test for the subscriber first -- Assembling the product cart test -- Invoking a saved cart event -- Confirming the saved cart -- Making the cart controller test run -- End-to-end testing -- Assembling the cart's end-to-end test -- Invoking a save to cart action -- Confirming products have been saved -- Making the cart's end-to-end test pass -- Self-test questions -- Summary -- 7. Give Me Some Data -- REST - the language of the Web -- Getting started with REST -- Testing asynchronous calls -- Creating asynchronous calls in Karma -- Creating asynchronous calls in Protractor -- Making REST requests using AngularJS -- Testing with AngularJS REST -- Testing the product service -- Testing http with Karma -- Mocking requests with Protractor -- Displaying products with REST -- Unit testing product requests -- Setting up the project -- Karma configuration -- Using an API builder pattern -- The product data service -- The product data controller -- Assembling the product controller test -- Getting products -- Asserting product data results -- Making the product data tests run -- Testing middle-to-end -- Test first -- Assembling the product test -- Getting products -- Expecting product data results -- Making the product data run -- Testing end-to-end -- Getting the product data -- Self-test questions -- Summary -- A. Integrating Selenium Server with Protractor -- Installation -- Protractor configuration -- Running Selenium -- Let it run.

Test first -- Assemble -- Assert -- Make it run -- Summary -- B. Automating Karma Unit Testing on Commit -- GitHub -- Test setup -- Test scripts -- Setting the hook -- Creating the hook -- Adding a Travis configuration file -- References -- C. Answers -- Chapter 1, Introduction to Test-driven Development -- Chapter 2, The Karma Way -- Chapter 3, End-to-end Testing with Protractor -- Chapter 4, The First Step -- Chapter 5, Flip Flop -- Chapter 6, Telling the World -- Chapter 7, Give Me Some Data -- Index.
Abstract:
This book is for developers who want to learn about AngularJS development by applying testing techniques. You are assumed to have a basic knowledge and understanding of HTML, JavaScript, and AngularJS.
Local Note:
Electronic reproduction. Ann Arbor, Michigan : ProQuest Ebook Central, 2017. Available via World Wide Web. Access may be limited to ProQuest Ebook Central affiliated libraries.
Electronic Access:
Click to View
Holds: Copies: