Angular 角度业力测试失败,自定义标记不是元素

Angular 角度业力测试失败,自定义标记不是元素,angular,karma-jasmine,Angular,Karma Jasmine,我正在学习角度,我的第一个业力测试抛出了下面的错误 AppComponent should create component Error: Template parse errors: 'ereturn-form' is not a known element: 1. If 'ereturn-form' is an Angular component, then verify that it is part of this module. 2. If 'ereturn-form' is a We

我正在学习角度,我的第一个业力测试抛出了下面的错误

AppComponent should create component
Error: Template parse errors:
'ereturn-form' is not a known element:
1. If 'ereturn-form' is an Angular component, then verify that it is part of this module.
2. If 'ereturn-form' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->]<ereturn-form></ereturn-form>"): ng:///DynamicTestModule/AppComponent.html@0:0
app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  template: '<ereturn-form></ereturn-form>',
})
export class AppComponent  { }
import { Component, OnInit, Input, OnChanges } from '@angular/core';

import { Ereturn } from './ereturn';
import { EreturnService } from './ereturn.service';
import { FormBuilder, FormGroup, Validators } from "@angular/forms";

@Component({
  selector: 'ereturn-form',
  templateUrl: './ereturn-form.component.html'
})

export class EreturnFormComponent implements OnInit {
...
}
这是我的规格文件

describe('1st tests', () => {
  it('true is true', () => expect(true).toBe(true));
});
为什么karma会抱怨自定义html标记?angular编译并运行得很好


非常感谢

如果您的元素是自定义组件,那么您应该将其作为声明的一部分添加到测试中

import{CustomElement}来自“…此处的路径”;
描述('AppComponent',()=>{
在每个之前(()=>{
TestBed.configureTestingModule({
模式:[],
声明:[CustomElement],
导入:[RouterTestingModule]
});
TestBed.compileComponents();

})
规格文件代码在哪里?更新到postThank@Aravind,我只是添加了规格文件一行是不够的。添加完整的规格文件您可能在创建规格文件模块时出错。
describe('1st tests', () => {
  it('true is true', () => expect(true).toBe(true));
});