javascript - how to mock providers specified in @component meta data in angular-2.0.0-rc-4 -
since, overrideproviders not supported in angular-2.0.0-rc-4.
i tried using
beforeeach(() => { addproviders([ testcomponentbuilder, feedslistcomponent, { provide: feedsservice, useclass: mockfeedsservice } ]);
});
i able mock service if provided @ bootstrap phase. if it's provided @componet level below
@component({ ... providers: ['feedsservice'] }) class feedslistcomponent { }
even if used provide it's not taking mockedservice. so, there alternative way mock services specified in @component meta data instead of overrideproviders
you need use overrideproviders
testcomponentbuilder
https://angular.io/docs/ts/latest/api/core/testing/testcomponentbuilder-class.html
Comments
Post a Comment