Angular 对象可能是未定义的角度单元测试
我在进行单元测试,但我发现错误率很低 对象可能是“未定义的” 我在里面出错了,这里的错误是什么Angular 对象可能是未定义的角度单元测试,angular,typescript,unit-testing,jasmine,karma-jasmine,Angular,Typescript,Unit Testing,Jasmine,Karma Jasmine,我在进行单元测试,但我发现错误率很低 对象可能是“未定义的” 我在里面出错了,这里的错误是什么 请让我知道。您应该在expect块中使用组件.dataSource而不是此.dataSource 您需要评估组件实例中定义的数据源 it('should set the dataSource filter to the provided argument', () => { component.applyFilter('filterValue'); expect(component.d
请让我知道。您应该在
expect
块中使用组件.dataSource
而不是此.dataSource
您需要评估组件
实例中定义的数据源
it('should set the dataSource filter to the provided argument', () => {
component.applyFilter('filterValue');
expect(component.dataSource.filter).toEqual('filterValue');
})
it('should set the dataSource filter to the provided argument', () => {
component.applyFilter('filterValue');
expect(component.DMDataSource.filter).toEqual('filterValue');
})
这回答了你的问题吗?M先生:我的回答有用吗?我打了勾,我还有一个问题要问,你能帮我吗
it('should set the dataSource filter to the provided argument', () => {
component.applyFilter('filterValue');
expect(component.dataSource.filter).toEqual('filterValue');
})
it('should set the dataSource filter to the provided argument', () => {
component.applyFilter('filterValue');
expect(component.DMDataSource.filter).toEqual('filterValue');
})