小编Per*_* Ch的帖子

如何使用 RouterTestingModule 测试路由导航

我想测试将我发送到特定页面的方法。我检查了几个示例,所有示例都以与我相同的方式完成,但我收到错误:

预期间谍导航已被调用: [ '/themen' ] 但它从未被调用。错误:预期间谍导航已被调用:[ '/themen' ] 但它从未被调用。

我的html代码是:

<button class="arrow-back-icon kf-tooltip-btn align-middle" id="backButton"
         tabindex="0" name="ic_arrow-back_24" (click)="goBack()">
</button>
Run Code Online (Sandbox Code Playgroud)

我的组件中的方法是:

import {AfterViewChecked, ChangeDetectorRef, Component, OnInit} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
import {SharingDataService} from '../services/sharing-data.service';
import {ActivatedRoute, Router} from '@angular/router';
import {BreakpointObserver} from '@angular/cdk/layout';
@Component({
  selector: 'app-meeting',
  templateUrl: './meeting.component.html',
  styleUrls: ['./meeting.component.scss']
})
export class MeetingComponent implements OnInit, AfterViewChecked {
  constructor(private readonly translate: TranslateService,
              private readonly sharingDataService: SharingDataService,
              private readonly router: Router,
              private readonly activatedRoute: ActivatedRoute,
              private readonly breakpointObserver: BreakpointObserver,
              private …
Run Code Online (Sandbox Code Playgroud)

unit-testing jasmine typescript angular angular11

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular ×1

angular11 ×1

jasmine ×1

typescript ×1

unit-testing ×1