Hi would like to test the real service with in my angular component. but im getting below error. No provider for Service blservice
import {async, getTestBed,TestBed, inject } from '@angular/core/testing';
import { BlService } from './bl.service';
import { Injectable } from '@angular/core';
import { BaseRequestOptions, Http, Response, ResponseOptions, XHRBackend} from '@angular/http';
describe('BlService', () => {
beforeEach(() => {TestBed.configureTestingModule({
providers: [BlService]
});
});
it('should be created', inject([BlService], (service: BlService) => {
expect(service).toBeTruthy();
}));
});
ERROR :
Error: No provider for BlService! Error: No provider for BlService!
at ReflectiveInjector_.prototype._throwOrNull (http://localhost:9876/_karma_webpack_/vendor.bundle.js:42115:13)
at ReflectiveInjector_.prototype._getByKeyDefault (http://localhost:9876/_karma_webpack_/vendor.bundle.js:42154:13)
at ReflectiveInjector_.prototype._getByKey (http://localhost:9876/_karma_webpack_/vendor.bundle.js:42086:13)
at ReflectiveInjector_.prototype.get (http://localhost:9876/_karma_webpack_/vendor.bundle.js:41955:9) at resolveNgModuleDep (http://localhost:9876/_karma_webpack_/vendor.bundle.js:48958:5) at NgModuleRef_.prototype.get (http://localhost:9876/_karma_webpack_/vendor.bundle.js:50028:9)
Solve it this way:
import {async} from '@angular/core/testing';
beforeEach(async(() => {
TestBed.configureTestingModule({
providers: [BlService]
});
}));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With