Since angular 2.0.0-rc.4 release (change log), both beforeEachProviders
and provide
are deprecated. My question is how can I inject my mocked service inside my component. Here is my beforeEach
function which creates a ComponentFixture
with overrided providers:
beforeEach(async(inject([TestComponentBuilder], (tcb)=> {
builder = tcb;
})));
beforeEach(async(inject([], ()=> {
return builder
.overrideProviders(MenubarComponent,[provide(MenubarService, {useClass:MenubarServiceMock})])
.createAsync(MenubarTestComponent)
.then((_fixture:ComponentFixture<any>)=> {
fixture = _fixture;
})
})));
This approach works fine but as I said provide
is deprecated.
What is the right way to do this without using provide()?
Aucun commentaire:
Enregistrer un commentaire