Find out how to unit test services in your Angular 2 application without using Angular's testing tools.
- [Instructor] Let's add a basic unit test…called a spec for our user list service…to confirm that it returns an array of 16 users.…We start by creating a new spec file…in our user list folder,…following the Angular convention…of keeping our unit tests…with the rest of our component code.…We'll create a new file…following Angular's naming conventions…of user dash list…dot service dot spec…dot T-S.…In our new file, we'll import the service…that we want to test…by creating an import statement at the top of the file.…
We then create a describe block,…which is a Jasmine function…that creates a group of tests called suites.…The first argument of the describe function…is an arbitrary string used to describe the suite.…You can call your suite whatever you'd like.…I'll call mine XyzUserListService.…The second argument is a callback function…that holds all of our tests.…We'll create a new property in this callback…to represent an instance of the service we want to test.…
We'll create a new line…and type let service…which will be of type XyzUserListService.…
- 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 2 Essential Trainingwith Justin Schwartzenberger2h 45m 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.