Find out how to unit test components in your Angular 2 application using Angular's testing tools.
- [Instructor] Let's create a unit test…for our app component to confirm…that it loads the correct title on initialization.…We start by opening our terminal…in the root of our application…and typing ng test.…This command launches the angular test server…and compiles our TypeScript code.…It will also watch our files for changes.…Back in our code editor,…we'll create a new file in the app folder…following the same naming convention…we used earlier in this course…of app.component.spec.ts.…
We'll add a describe block…and call our test suite AppComponent.…We need to import some support classes…that are built into Angular…to help bootstrap the component…and give us access to all the instance functions…and DOM elements.…At the top of our file,…we'll create new import statements…and import the TestBed class…and ComponentFixture class…from angular/core/testing.…The By class from angular/platform-browser…and the DebugElement class from angular/core.…
We use the TestBed class…to configure our in-test app module,…and resolve any dependencies our component might need.…
- Analyzing Angular 2 error messages
- Identifying the causes of common error messages
- Preventing common errors with custom error handling
- Analyzing testing reports
- Reviewing common testing report errors and their likely causes
Skill Level Intermediate
Angular Essential Trainingwith Justin Schwartzenberger2h 48m Intermediate
Angular 2: Widget-Based Architectureswith Derek Peruo52m 18s Intermediate
1. Getting Started
Application overview1m 49s
2. How Angular 2 Reports Errors
Error handling in Angular1m 21s
3. Common Angular 2 Errors
4. Testing Angular 2 Applications
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.