Testing Angular Applications Covers Angular 2
Ingenaaid Engels 2019 1e druk 9781617293641Samenvatting
The Angular 2 framework is great for building large-scale web applications that can be maintained and extended. And when building enterprise-level apps, testing is vital to the development process.
Testing improves the quality of code and reduces maintenance, saving both time and money. Even though testing is crucial, it's sometimes neglected since there are few established resources and standards when it comes to modern JavaScript web applications. Developers who know how to build and leverage tests are highly valued by their clients and companies.
Testing Angular Applications is an example-rich, hands-on guide that gives the real-world techniques needed to thoroughly test all parts of Angular 2 applications. The book starts with an introduction to Angular 2, TypeScript, testing fundamentals, and the testing frameworks and tools used in the book. Next, it explains how to set-up an Angular 2 environment, including TypeScript and the Angular 2 dependencies. The reader will then create their first component. The second part of the book focuses on the most important concepts of Angular 2, such as testing components, directives, pipes, services, and routing. This book will allow readers to confidently write unit and endto-end tests for Angular 2 applications and TypeScript.
Key features
- Testing components, directives, services and pipes
- Real-world techniques
- Hands-on examples
- Foundation for writing advances tests
- Provides code that can be reused in a production environment
This book is for readers with intermediate JavaScript skills and some experience with JavaScript frameworks. No experience with testing or Angular required.
About the Technology
Angular 2 is the latest version of the popular web application framework built by Google and its army of community contributors. Angular 2 is a mobile-first framework that promises to be fast, flexible, and expressive. The Angular 2 syntax is clean and easy to read, which lends itself nicely to rapid development and assists in writing tests.
Specificaties
Lezersrecensies
Inhoudsopgave
1.1. Angular Testing Overview
1.2. Getting friendly with TypeScript
1.3. A closer look at test types
1.3.1. Unit Tests
1.3.2. End-to-End Tests
1.3.3. Unit Tests vs End-to-End Tests
PART 1: UNIT TESTING
2. CREATING YOUR FIRST TESTS
2.1. Writing basic tests using Jasmine
2.1.1. Writing basic tests
2.2. Testing Classes
3. TESTING COMPONENTS
3.1. What are directives?
3.1.1. Components vs. directives
3.1.2. Different directives
3.2. Real-world component testing
3.2.1. Importing the dependencies
3.2.2. Setting up the tests
3.2.3. Adding the tests
4. TESTING DIRECTIVES
4.1. What are directives?
4.1.1. Components vs. directives
4.1.2. Different directives
4.2. Testing attribute directives
4.2.1. Introducing the favorite icon directive
4.2.2. Creating tests for FavoriteIconDirective
4.2.3. Setting up the FavoriteIconDirective test suite
4.2.4. Creating the FavoriteIconDirective tests
4.3. Testing structural directives
4.3.1. Introducing ShowContactsDirective
4.3.2. Creating your tests for ShowContactsDirective
4.3.3. Setting up the ShowContactsDirective test suite
4.3.4. Creating the ShowContactsDirective tests
5. TESTING PIPES
5.1. Introducing PhoneNumberPipe
5.2. Testing PhoneNumberPipe
5.2.1. Getting Started
5.2.2. Testing the default usage for a pipe
5.2.3. Testing pipes with a single parameter
5.2.4. Pipes with multiple parameters
6. TESTING SERVICES
6.1. What are services?
6.2. How do services work in Angular?
6.2.1. Dependency Injection
6.2.2. The @Injectable() class decorator
6.3. Creating services with Angular CLI
6.4. Testing PreferencesService
6.4.1. Testing for failures
6.5. Testing services with promises
6.5.1. How asynchronous changes testing
6.5.2. Testing for failures with asynchronous services
6.6. Testing HTTP services with observables
7. TESTING ROUTER
7.1. What is the Angular router?
7.1.1. Configuring the router
7.2. Testing routed components
7.2.1. Testing router navigation with RouterTestingModule
7.2.2. Testing router parameters
7.3. Testing advanced routes
7.3.1. Route guards
7.3.2. Resolving data before loading a route
PART 2: END-TO-END TESTING
8. GETTING STARTED
8.1. How Protractor works
8.2. Writing your first Protractor test
8.2.1. File structure
8.3. Installing and running
8.4. Interacting with elements
8.4.1. Test scenario: creating a new contact
8.4.2. Test scenario: workflows that don’t create a new contact
8.5. by and element methods
8.6. Interacting with a list of elements
8.6.1. Filtering web elements
8.6.2. Mapping the contact list to an array
8.6.3. Reduce
8.7. Page Objects
9. UNDERSTANDING TIMEOUTS
9.1. Kinds of timeouts
9.2. Testing pages without Angular
9.2.1. Disabling waitForAngular
9.2.2. Automatically waiting for Angular
9.2.3. When to use browser.waitForAngularEnabled()
9.3. Waiting with ExpectedConditions
9.3.1. Waiting for the contact list to load
9.3.2. Testing a dialog
9.3.3. Waiting for elements to become stale
9.4. Creating custom conditions
9.4.1. Using browser.wait
9.4.2. Getting elements from the browser
9.5. Handling long-running tasks
9.5.1. Using expected conditions
9.5.2. The browser event loop
9.5.3. What happened to $timeout?
9.5.4. Highway to the Angular zone
9.5.5. Fixing the test
10. ADVANCED PROTRACTOR TOPICS
10.1. Configuration file in depth
10.1.1. Driver Provider Options
10.1.2. Desired capabilities
10.1.3. Plugins
10.1.4. Environment variables
10.2. Screenshot testing
10.2.1. Taking screenshots
10.2.2. Taking screenshots on test failure
10.2.3. Comparing screenshots
10.3. Experimental debugging features
10.3.1. WebDriver Log
10.3.2. Highlight Delay
10.3.3. Blocking Proxy
10.4. The control flow and debugging with Chrome DevTools
10.4.1. Asynchronous functions and promises
10.4.2. The WebDriver Control Flow
10.4.3. The future: async/await
10.4.4. Using Chrome DevTools
PART 3 CONTINUOUS INTEGRATION
11. CONTINUOUS INTEGRATION
11.1. Jenkins
11.1.1. Setting up Jenkins
11.1.2. Unit tests
11.1.3. E2E tests
11.2. Circle CI
APPENDIXES
APPENDIX A: SETTING UP THE SAMPLE PROJECT
A.1. Introducing the Angular CLI
A.2. Installing prerequisites
A.2.1. Installing the Angular CLI the first time
A.2.2. Updating an old version of the Angular CLI
A.3. Installing the sample project
A.4. Installing dependencies
A.5. Running the application
APPENDIX B: ADDITIONAL RESOURCES
B.1. Angular testing
B.2. General testing
Rubrieken
- advisering
- algemeen management
- coaching en trainen
- communicatie en media
- economie
- financieel management
- inkoop en logistiek
- internet en social media
- it-management / ict
- juridisch
- leiderschap
- marketing
- mens en maatschappij
- non-profit
- ondernemen
- organisatiekunde
- personal finance
- personeelsmanagement
- persoonlijke effectiviteit
- projectmanagement
- psychologie
- reclame en verkoop
- strategisch management
- verandermanagement
- werk en loopbaan