title: How to inject arguments to a constructor of a service for testing using jasmine testbed.configureTestingModule
body: <p>Hi I need to pass two arguments to my constructor when testing using testBed.configureModule</p>
  
  <p>Here is my base.service.spec.ts</p>
  
  <pre class="lang-ts prettyprint-override"><code>import { TestBed } from '@angular/core/testing';
  import { HttpClientTestingModule } from '@angular/common/http/testing';
  import { BaseService } from '@shared/services/base/base.service';
  import { HttpHeaders, HttpClient } from '@angular/common/http';
  
  describe('BaseService', () =&gt; {
  
      let baseService: BaseService&lt;any&gt;, httpClientTestingModule: HttpClientTestingModule;
  
      beforeEach(() =&gt; {
  
          TestBed.configureTestingModule({
              imports: [HttpClientTestingModule],
              providers: [BaseService,
                  { provide: HttpClientTestingModule, useValue: httpClientTestingModule },
                  { provide: String, useValue: 'base' }
              ]
          })
  
          baseService = TestBed.get(BaseService)
          //httpClientTestingModule = TestBed.get(HttpClientTestingModule)
  
      })
  
      const GET_BASE_URL = 'getBaseURL'
      //Test getBaseUrl
      it(`${GET_BASE_URL} should return a string`, () =&gt; {
  
          baseService.getBaseURL().then((base) =&gt; {
              if (base) {
                  //PASSED if base is a string
                  expect(base).toEqual(jasmine.any(String), 'Result is not a string')
              } else {
                  fail(`${GET_BASE_URL} failed: string was empty or null`)
              }
          }, (error) =&gt; {
              fail(`${GET_BASE_URL} failed: promise was not resolved`)
          })
  
      })
  
      const GET_PROVIDER_HEADER = 'getProviderOnlyHeader'
      //Test getProviderOnlyHeader
      it(`${GET_PROVIDER_HEADER} should return HttpHeaders`, () =&gt; {
  
          let result = baseService.getProviderOnlyHeader()
  
          expect(result).toEqual(jasmine.any(HttpHeaders), 'Result is not a HttpHeader')
      })
  
  })
  </code></pre>
  
  <p>And here is a portion of my base.service.ts</p>
  
  <pre class="lang-ts prettyprint-override"><code>export class BaseService&lt;T&gt; {
  
    nativeStorage: NativeStorage;
  
    //A single object
    _item = new BehaviorSubject&lt;T&gt;(null);
  
    //A list of items
    _list = new BehaviorSubject&lt;T[]&gt;(null);
  
    get item() {
      return this._item.asObservable();
    }
  
    getCurrentItem() {
      return this._item.getValue()
    }
  
    getCurrentList() {
      return this._list.getValue()
    }
  
    get list() {
      return this._list.asObservable();
    }
  
    constructor(public http: HttpClient, public controllerName: string) {
  
      this.nativeStorage = new NativeStorage();
  
      this.getBaseURL().then((base) =&gt; {
        BASE = base
      })
    }
  }
  </code></pre>
  
  <p>I know there are similar questions but I can't find a solution
  How should my testBed setup look like?</p>
  
  <p>Anymore detail required let me know thanks in advance</p>
  
  <p>Also getting this error message</p>
  
  <blockquote>
    <p>Error: Can't resolve all parameters for BaseService: (?, ?).</p>
  </blockquote>
  
  <p>Also base service is a super class, its not really a service
  The base service arguments are injected in the super method, example below</p>
  
  <pre><code>@Injectable({
      providedIn: 'root'
  })
  export class AccessService extends BaseService&lt;any&gt; {
  
      private _providers = new BehaviorSubject&lt;any&gt;(null);
  
      get providers() {
          return this._providers.asObservable();
      }
  
      currentProviders() {
          return this._providers.getValue();
      }
  
      constructor(http: HttpClient) {
          super(
              http,
              controllerName)
  
          this.getBaseURL().then((base) =&gt; {
              BASE = base
          })
      }
  
      getProviders() {
          return this.http.get&lt;any&gt;(BASE + docketName + environment.API_V2 + 'providers')
              .pipe(
                  map(resp =&gt; {
                      return resp.content
                  }),
                  tap(result =&gt; {
                      this._providers.next(result)
                  })
              );
      }
  }
  </code></pre>