title: How to mock a service that contains a static variable?
body: <p>I have a question ? How can I mock a service that contains static variable?</p>
  
  <p>This is my service</p>
  
  <pre><code>@Injectable()
  
  
  export class AppConfigService {
  
      static settings: IAppConfig;
      constructor(private http: HttpClient) {}
  
      load() {
          const jsonFile = `assets/config/config.${environment.name}.json`;
          return new Promise&lt;void&gt;((resolve, reject) =&gt; {
              this.http.get(jsonFile).toPromise().then((response: IAppConfig) =&gt; {
                  AppConfigService.settings = response as IAppConfig;
                  resolve();
              }).catch((response: any) =&gt; {
                  reject(`Could not load file '${jsonFile}': ${JSON.stringify(response)}`);
              });
          });
      }
  }
  </code></pre>
  
  <p>an this is my unit-test code:</p>
  
  <pre><code>describe('AppConfigService', () =&gt; {
      let service: AppConfigService;
      beforeEach(() =&gt; {
          TestBed.configureTestingModule({
              imports: [
                  HttpClientTestingModule
              ],
              providers: [
                  {provide: AppConfigService, useClass: MockAppConfigService}
              ]});
          service = TestBed.get(AppConfigService);
      });
  
      it('should be created', () =&gt; {
          expect(service).toBeTruthy();
      });
      it('should ran load well', () =&gt; {
          expect(service.settings)......;
      });
  </code></pre>
  
  <p>I can not use service.settings, because settings is a static member of AppConfigService...... </p>