Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 对象可能是未定义的角度单元测试_Angular_Typescript_Unit Testing_Jasmine_Karma Jasmine - Fatal编程技术网

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');
 })