angular - Can't resolve all parameters for ObservableDataSource: ([object Object], ?)



I am currently using the angular material data-table cdk. In order to hook up my ngrx/store into the data-table CDK, I am extending the connect method for the DataSource CDK, to allow for an observable to be injected. The following is the relevant code for this question

export class ObservableDataSource extends DataSource<any> {
  private value: any[];
  private key: string;
  constructor(value: any[], key) {
    this.value = value;
    this.key = key;

  connect() {
    return combineLatest(this.value, (data) => {
      return data[this.key];

  disconnect() {} 

When unit testing this component(which for curious minds has a @Component decorator, just not shown), I receive the following error: Failed: Can't resolve all parameters for ObservableDataSource: ([object Object], ?).

I then proceeded to provide values for both value and key:

beforeEach(async(() => {
      declarations: [ ObservableDataSource ],
        {provide: 'value', useValue: []},
        {provide: 'key', useValue: ''},

However, the error Failed: Can't resolve all parameters.. still shows up. Any suggestions as to how I can properly provide for constructor values, so that Jasmine/Karma can properly resolve parameters is more than appreciated. Thank you.

1 Answer: 

After looking into it a bit more, I did the following to make it work. First, I realized that this is a service, not a component. So i switched over my @Component() decorator for @Injectable. Second, I provided the service with a value of the constructed service as follows:

providers: [
   {provide: ObservableDataSource, useValue: new ObservableDataSource([], 'visible')}

This solved the above issue, and allowed me to continue using TestBed.