title: How to reuse all imports in Angular test files
body: <p>Lets say I have a simple module <code>AppModule</code> which has many imports, declarations and providers. Now I want to write a test for a component <code>ListComponent</code> which is located in this module's declaration list. <code>ListComponent</code> itself uses many, (but not every) import of the <code>AppModule</code>. I do it like this:</p>
  
  <pre><code>import { TestBed } from '@angular/core/testing';
  // +same copy-pasted list of imports from `AppModule`
  
  beforeEach(done =&gt; {
      TestBed.configureTestingModule({
          imports: [
              // +same copy-pasted list of imports from `AppModule`
          ],
          declarations: [
              // +same copy-pasted list of declarations from `AppModule`
          ],
          providers: [
              {
                  provide: Http,
                  useClass: HttpMock,
              },
              {
                  provide: Router,
                  useClass: RouterMock,
              }
              // +same copy-pasted list of providers from `AppModule`
          ]
      });
  </code></pre>
  
  <p>It works, but surely it is an incorrect approach. I do not want to copy-paste so much. Maybe I can reuse the AppModule in some convenient approach? Pseudocode would be like:</p>
  
  <pre><code>let appModule = new AppModule();
  
  beforeEach(done =&gt; {
      TestBed.configureTestingModule({
          imports: appModule.imports,
          declarations: appModule.declarations,
          providers: [...appModule.providers,
              {
                  provide: Http,
                  useClass: HttpMock,
              },
              {
                  provide: Router,
                  useClass: RouterMock,
              }
          ]
      });
  </code></pre>
  
  <p>But I just do not know/cannot find the syntax for such approach :(</p>