Angular,Jasmine:TypeError无法读取属性' filter'未定义的。

时间:2018-03-30 13:38:17

标签: angular jasmine karma-jasmine angular-material2

我尝试对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

欢迎使用其他测试此包装的建议。

0 个答案:

没有答案