我尝试对MatRadioGroup包装器进行单元测试但继续获取TypeError: Cannot read property 'filter' of undefined jasmine
。
规范应该通过,但我不知道为什么在测试运行时过滤掉未定义的错误。
以下是规范:
it('should test the properties of the component', () => {
options = [
{
value: 'Option 1',
displayValue: 'Option 1',
}, {
value: 'Option 2',
displayValue: 'Option 2',
checked: true,
}
];
component.options = options;
component.color = 'primary';
fixture.detectChanges();
let radioElement = fixture.debugElement.query(By.css('.mat-radio-button'));
console.log(radioElement);
expect(radioElement.attributes['ng-reflect-color']).toEqual('primary');});
这里是stackblitz:https://stackblitz.com/edit/radio-group-wrapper
欢迎使用其他测试此包装的建议。