Angular 测试以角度返回FormGroup的函数时出错

Angular 测试以角度返回FormGroup的函数时出错,angular,typescript,unit-testing,angular8,formbuilder,Angular,Typescript,Unit Testing,Angular8,Formbuilder,我的服务文件中有以下功能。它返回一个FormGroup,我们需要在多个位置动态返回该FormGroup,因此将其放入服务中 createBaseForm(){ 返回此.fb.group({ 标题:[''[Validators.required,Validators.maxLength(200)], 说明:[ '', [ 需要验证器, 验证程序.最大长度(2000), 这个.whitespaceValidator, ], ], }); } 我为这个函数编写的测试如下。我只是调用该函数并将其与预期

我的服务文件中有以下功能。它返回一个FormGroup,我们需要在多个位置动态返回该FormGroup,因此将其放入服务中

createBaseForm(){
返回此.fb.group({
标题:[''[Validators.required,Validators.maxLength(200)],
说明:[
'',
[
需要验证器,
验证程序.最大长度(2000),
这个.whitespaceValidator,
],
],
});
}
我为这个函数编写的测试如下。我只是调用该函数并将其与预期结果匹配,但它失败了

it('createBaseForm',()=>{
const服务:CompareService=TestBed.get(CompareService);
const baseform=新表单组({
标题:新表单控件([
'',
[Validators.required,Validators.maxLength(200)],
]),
描述:新表单控件([
'',
[
需要验证器,
验证程序.最大长度(2000),
这个.whitespaceValidator,
],
]),
});
expect(service.createBaseForm()).toEqual(baseform);
});
我得到以下错误

 CompareService createBaseForm FAILED
        Error: Expected $._onCollectionChange = Function to equal Function.
        Expected $.controls.title.validator = Function to equal null.
        Expected $.controls.title._onCollectionChange = Function to equal Function.
        Expected $.controls.title._pendingValue = '' to equal [ '', [ Function, Function ] ].
        Expected $.controls.title.value = '' to equal [ '', [ Function, Function ] ].
        Expected $.controls.title.status = 'INVALID' to equal 'VALID'.
        Expected $.controls.title.errors = Object({ required: true }) to equal null.
        Expected $.controls.description.validator = Function to equal null.
        Expected $.controls.description._onCollectionChange = Function to equal Function.
        Expected $.controls.description._pendingValue = '' to equal [ '', [ Function, Function, undefined ] ].
        Expected $.controls.description.value = '' to equal [ '', [ Function, Function, undefined ] ].
        Expected $.controls.description.status = 'INVALID' to equal 'VALID'.
        Expected $.controls.description.errors = Object({ required: true, whitespace: true }) to equal null.
        Expected $.status = 'INVALID' to equal 'VALID'.
        Expected $.value.title = '' to equal [ '', [ Function, Function ] ].
        Expected $.value.description = '' to equal [ '', [ Function, Function, undefined ] ].
我不知道如何继续进行。我是否应该测试每个表单字段以检查其是否有效?有人能帮忙吗