title: AngularJS Jasmine Unit Tests
body: <p>I have the following unit tests, and for some reason the second test makes other tests fail.</p>
  
  <pre><code>beforeEach(inject(function ($rootScope, _$httpBackend_, $controller, $location, mockedResource) {
      scope = $rootScope.$new();
      httpBackend = _$httpBackend_;
      locationService = $location;
  
      ctrlDependencies = {
          $scope: scope, 
          resource: mockedResource,
      }
  
      var ctrl = $controller('myController', ctrlDependencies);
  }));
  
  it('should redirect to a new page', function() {
      scope.pageRedirectFunction();
      expect(locationService.path()).toBe('/newpage')
  });
  
  it('should delete an epic resource', function() {
      httpBackend.expectGET('/api/v1/epic/1').respond({});
      httpBackend.expectDELETE('/api/v1/epic/1').respond({});
  
      // Run the deletion function
      scope.deleteEpicResource()
  
      httpBackend.flush() // This line seems to be the rebelious one
  
      expect(scope.epicResources.length).toEqual(0)
  })
  </code></pre>
  
  <p>I have managed to figure out the line that seems to cause the errors, and it's the <code>httpBackend.flush()</code> line. Why is the flush function causing strange behaviour?</p>
  
  <p>The actual error I get from running the command <code>karma start</code> in the terminal, is:</p>
  
  <pre><code> Delaying execution, these browsers are not ready: Chrome 29.0 ....
  </code></pre>
  
  <p>after a little while, the Chrome session then crashes.</p>