NullInjectorError: R3InjectorError(DynamicTestModule)[MyService -> MyService]:
NullInjectorError: No provider for MyService!
Stack:
error properties: Object({ ngTempTokenPath: null, ngTokenPath: [ 'MyService', 'MyService' ] })
at <Jasmine>
at get (http://localhost:9999/_karma_webpack_/vendor.js:79605:9)
at get (http://localhost:9999/_karma_webpack_/vendor.js:92078:9)
at get (http://localhost:9999/_karma_webpack_/vendor.js:92078:9)
at get (http://localhost:9999/_karma_webpack_/vendor.js:107817:7)
at get (http://localhost:9999/_karma_webpack_/vendor.js:105635:7)
at getOrCreateInjectable (http://localhost:9999/_karma_webpack_/vendor.js:82976:9)
at ɵɵdirectiveInject (http://localhost:9999/_karma_webpack_/vendor.js:95333:3)
at LoadingCircleComponent_Factory (Function code:3:3)
at getNodeInjectable (http://localhost:9999/_karma_webpack_/vendor.js:83102:7)
at instantiateRootComponent (http://localhost:9999/_karma_webpack_/vendor.js:88076:3)
Код:
describe('MyService', () => {
let service: MyService;
const appServiceStub = {
log: {
info: () => {},
warn: () => {}
}
};
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
{
provide: AppService,
useValue: appServiceStub
}
]
});
service = TestBed.inject(MyService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
так добавь MyService в providers
Обсуждают сегодня