karma-jasmine

Angular 2 and Jasmine unit testing: cannot get the innerHtml

泄露秘密 提交于 2020-12-08 06:20:01
问题 I am using one of the examples that test a component 'WelcomeComponent': import { Component, OnInit } from '@angular/core'; import { UserService } from './model/user.service'; @Component({ selector: 'app-welcome', template: '<h3>{{welcome}}</h3>' }) export class WelcomeComponent implements OnInit { welcome = '-- not initialized yet --'; constructor(private userService: UserService) { } ngOnInit(): void { this.welcome = this.userService.isLoggedIn ? 'Welcome ' + this.userService.user.name :

Angular: Unit testing lazy-loaded modules with routing

霸气de小男生 提交于 2020-12-07 03:02:33
问题 I'm facing some issues testing lazy-loaded modules in Angular. This is my .spec file: import { Location } from '@angular/common'; import { TestBed, ComponentFixture } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { Router } from '@angular/router'; import { routes } from './app-routing.module'; import { AppComponent } from './app.component'; import { AppConfigService } from './services/appConfig.service'; import { TranslateModule } from '