小编Ama*_*lin的帖子

类型错误:_this.handler.handle 不是函数错误

我收到此错误,即 this.handler.handle 不是我在 Angular 6 中使用 karma/jasmine 进行的单元测试中的函数。当我在我的项目文件夹中输入“ng test”命令时,这个错误出现在我的命令行中。

Chrome 67.0.3396 (Windows 10.0.0) AppComponent should create FAILED    
Failed: _this.handler.handle is not a function
TypeError: _this.handler.handle is not a function
Run Code Online (Sandbox Code Playgroud)

对于应该创建 AppComponent 的测试,这里是我的 .spec 文件

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormsModule, FormBuilder } from '@angular/forms';
import { HttpClientModule, HttpClient, HttpHandler } from '@angular/common/http';
describe('AppComponent', () => {
  let …
Run Code Online (Sandbox Code Playgroud)

httphandler karma-jasmine angular

9
推荐指数
2
解决办法
9810
查看次数

标签 统计

angular ×1

httphandler ×1

karma-jasmine ×1