title: Angular2 unit testing beforeEach block too slow
body: <p>This is my before each block for unit testing. It works great, making a new component instance available for each test. However, it takes approx 4 secs to execute the beforeEach block. When you've got 200 tests, that is slow!</p>
  
  <p>I want to move the bulk of the code to a beforeAll block (which works if you use the Jasmine <code>done()</code> callback instead of using async) but I still am unable to create a new instance for each test. Some tests fail because the sole instance has been tampered with by previous tests.</p>
  
  <p>How do I ...</p>
  
  <ol>
  <li>Create a new component instance without executing this time consuming code for EVERY test.</li>
  </ol>
  
  <p>or</p>
  
  <ol start="2">
  <li>Reset the instance to its untampered with state.</li>
  </ol>
  
  
  
  <pre><code>beforeEach(async(() =&gt; {
      TestBed.configureTestingModule({
        imports: [AppModule],
        providers: [{provide: APP_BASE_HREF, useValue: '/'},
          MockBackend,
          BaseRequestOptions,
          {
            provide: Http,
            useFactory: (pBackend: MockBackend, pOptions: BaseRequestOptions) =&gt; {
              return new Http(pBackend, pOptions);
            },
            deps: [MockBackend, BaseRequestOptions]
          }]
      }).compileComponents()
        .then(() =&gt; {
          fix = TestBed.createComponent(Route1DetailComponent);
          instance = fix.componentInstance;
          injector = fix.debugElement.injector;
        });
  }));
  </code></pre>