Angular Unit Test

13 Nov 2017

The tests

Jasmine runs the beforeEach function before each of these tests

Test a component

Test a component with an external template

Test a component with a dependency

Always get the service from an injector

userService = TestBed.get(UserService);

or

Automatic change detection

import { ComponentFixtureAutoDetect } from '\@angular/core/testing';

providers: [ { provide: ComponentFixtureAutoDetect, useValue: true } ]

Tags: