title: How to reuse beforeEach/afterEach in Jasmine JS?
body: <p>When writing tests with JasmineJS I have many tests that have similar beforeEach/afterEach code.</p>
  
  <p>Is there a way to implement an inheritance model using JasmineJS test suites?</p>
  
  <p>I can group all tests in a single <code>describe</code> but in this case I will end with a single HUGE JS file containing all tests.</p>
  
  <p>I would like to split the tests for each page.</p>
  
  <p>Here is an example:</p>
  
  <pre><code>describe('Services Page', function() {
  
      beforeEach(function() {
          login_as_admin()
      })
  
      beforeEach(function() {
          browser().navigateTo('/services')
      })
  
      if('Some test for services page', function() {})
  
      afterEach(function() {
          logout()
      })
  
  })
  
  
  describe('Administrators Page', function() {
  
      beforeEach(function() {
          login_as_admin()
      })
  
      beforeEach(function() {
          browser().navigateTo('/administrators')
      })
  
      if('Some test for administrators page', function() {})
  
      afterEach(function() {
          logout()
      })
  
  })
  </code></pre>