jeudi 13 avril 2017

Instantiate a provider in TestBed with the instance of another provider

How do you instantiate a provider in TestBed.configureTestingModule() with an instance of another provider?

An example (doesn't work obviously):

beforeEach(() => {
  TestBed.configureTestingModule({
    providers: [
      { provide: ServiceOne, useValue: new ServiceOne('parameterOne')},
      { provide: ServiceTwo, useValue: new ServiceTwo(TestBed.get(ServiceOne), 'parameterTwo')}
    ]
  });
});

Aucun commentaire:

Enregistrer un commentaire