title: Angular unit tests for services that uses TranslateService
body: <p>How do I have to use the TranslateService in unit tests of a service?
  TranslateService is used in the service class in that way:</p>
  
  <pre><code>export class ErrorControllerService {
      constructor(public translate: TranslateService) {
      }
      ...
  }
  </code></pre>
  
  <p>And I tried to configure the TestingModule TestBed in that way:</p>
  
  <pre><code>import { MyService } from './myservice';
  import { TestBed } from '@angular/core/testing';
  
  describe('MyService', () =&gt; {
    let myService:MyService;
    beforeEach(() =&gt; {
      TestBed.configureTestingModule({
        declarations: [ ],
        imports: [
                  TranslateModule.forRoot({
                      loader: {
                          provide: TranslateLoader,
                          useFactory: HttpLoaderFactory,
                          deps: [HttpClient]
                      }
                      }),
        ],
        providers: [ MyService, TranslateService ],
      });
      let myService = TestBed.get(MyService);
    });
  
    it('should be created', () =&gt; {
      expect(myService).toBeDefined();
    });
  });
  </code></pre>
  
  <p>During running of <strong>npm test</strong> I get this message</p>
  
  <pre><code>NullInjectorError: StaticInjectorError(DynamicTestModule)[TranslateService]: 
    StaticInjectorError(Platform: core)[TranslateService]: 
      NullInjectorError: No provider for TranslateService!
  error properties: Object({ ngTempTokenPath: null, ngTokenPath: [ Function ] })
      at &lt;Jasmine&gt;
      at NullInjector.get (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:778:1)
      at resolveToken (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:2564:1)
      at tryResolveToken (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:2490:1)
      at StaticInjector.get (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:2353:1)
      at resolveToken (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:2564:1)
      at tryResolveToken (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:2490:1)
      at StaticInjector.get (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:2353:1)
      at resolveNgModuleDep (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:26403:1)
      at NgModuleRef_.get (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:27491:1)
      at injectInjectorOnly (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:657:1)
  </code></pre>
  
  <p>Any idea, what I do wrong? My research showed me just examples with a component, but not with a service.</p>