this.fb.group({在angular中不是函数?

this.fb.group({在angular中不是函数?,angular,karma-jasmine,angular2-forms,mean,angular-unit-test,Angular,Karma Jasmine,Angular2 Forms,Mean,Angular Unit Test,我有以下代码 ** component.ts, constructor(public cdr:ChangeDetectorRef, public fb:FormBuilder) { this.buildForm(); } buildForm(): void { this.feedbackForm = this.fb.group({ suggestedAScore: ['', [Validators.pattern(/^[0-9]+$/),Validators.requi

我有以下代码

** component.ts,

 constructor(public cdr:ChangeDetectorRef, public fb:FormBuilder) { 
   this.buildForm();
 }



buildForm(): void {
 this.feedbackForm = this.fb.group({
  suggestedAScore: ['', [Validators.pattern(/^[0-9]+$/),Validators.required, Validators.maxLength(5), Validators.minLength(5)]],
  minScore: ['', [Validators.pattern(/^[0-9]+$/),Validators.required,Validators.minLength(1),Validators.maxLength(1)]],
  maxScore: ['', [Validators.pattern(/^[0-9]+$/),Validators.required,Validators.minLength(1),Validators.maxLength(1)]]
});
 this.feedbackForm.setValidators(this.minMaxValidator());
this.isFeedbackFormValid();
};
**规范ts(浅层抹灰)


我不熟悉单元测试用例。谁能建议我帮助解决这个问题。

您可以使用
neverMock
初始化
FormGroup
模块

从'@angular/forms'导入{FormsModule};
描述('反馈选项组件',()=>{
浅层。neverMock(FormsModule);
在每个之前(()=>{
浅层=新浅层(反馈选项组件、年度补偿模块);
});
});
 describe('FeedbackOptionsComponent', () => {
  let shallow: Shallow<FeedbackOptionsComponent>;

 beforeEach(() => {
   shallow = new Shallow(FeedbackOptionsComponent, AnnualCompensationModule)
   .provide(FormBuilder)
 });

  it('should create', () => {
    expect(FeedbackOptionsComponent).toBeTruthy();
 });
this.fb.group({ is not a function