angular-testing

unable to test Routing using RouterTestingModule

亡梦爱人 提交于 2019-12-24 00:36:11
问题 I have a component which uses Routes . I want to unit test the routes but am unale to do so using RouterTestingModule . The spec I have written is import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing'; .... fdescribe('HomepageContentComponentComponent', () => { let component: HomepageContentComponentComponent; let fixture: ComponentFixture<HomepageContentComponentComponent>; beforeEach(() => { TestBed.configureTestingModule({ imports:[ RouterTestingModule

How can I get reference of child component and emit a value from child component

℡╲_俬逩灬. 提交于 2019-12-11 15:07:29
问题 I have a parent component ValidateSessionComponent which has a child component LoginFormComponent . In my unit test, I want to emit a value from LoginFormComponent but I am unable to figure out how I can do so. The HTML of the ValidateSessionComponent has reference of the LoginFormComponent . <app-login-form #loginForm (formOutputEvent)="handleFormValues($event)" [userId]="username"></app-login-form> The LoginFormComponent looks like export class LoginFormComponent implements OnInit {

Angular Testing Error: Can't resolve all parameters for Service:

大城市里の小女人 提交于 2019-12-10 17:48:01
问题 I'm new to testing. I have a service and a spec file that when run I get the following error: Error: Can't resolve all parameters for DashboardService: (?). error properties: Object({ ngSyntaxError: true }) The spec file looks like this: import { TestBed } from '@angular/core/testing'; import { DashboardService } from './dashboard.service'; import { ApiService } from './../api.service'; describe('The Dashboard Service', () => { beforeEach(() => { TestBed.configureTestingModule({ providers: