【发布时间】:2022-07-30 08:15:58
【问题描述】:
我有一个matInput 用于更新组件属性:
<input matInput [(ngModel)]="componentProperty" />
<div>componentProperty value is: {{ componentProperty }}</div>
当我使用它时,它会起作用:显示的 componentProperty 值与我放入框中的值匹配。
但是,我为此编写的单元测试不起作用:
it('should update componentProperty to match input box value', async () => {
const inputHarness = await loader.getHarness(
MatInputHarness
);
const testValue = 'hello';
expect(component.componentProperty).toEqual('');
await inputHarness.setValue(testValue);
expect(component.componentProperty).toEqual(testValue);
});
这失败了 Expected '' to equal 'hello'. 给出了什么?
【问题讨论】:
标签: angular angular-material jasmine