title: Full stack testing Ember.js and Laravel app
body: <p>I am working out how best to test an application we are developing using Laravel as backend (REST API) and Ember.js as front end. </p>
  
  <p>I am currently using Behat to run acceptance tests for the API. I would like to use Cucumber.js to also create and test features for the Ember side of the project. </p>
  
  <p>I already have an "acceptance" environment dedicated to running the Behat features in the API. </p>
  
  <p>The issue I can see with "full stack" testing from the JS side is how to clean and reseed the database? </p>
  
  <p>My thoughts are to add a route for testing purposes only, e.g.:</p>
  
  <pre><code>if ( App::environment() == 'acceptance' ) {
      Route::get('/test/reseed', function() {
          // delete db if exists
          Artisan::call('migrate');
          // call other migrations...  
          Artisan::call('db:seed');
          return "ok";
      });
  } 
  </code></pre>
  
  <p>This way only the acceptance environment has access to that call, and it should be all thats needed to set up the API side of things ready for Cucumber.js &amp; Ember to run the tests (probably via Node.js)</p>
  
  <p>I'm asking here to see if there is anything glaring I might have missed, if there is another way to do this.</p>
  
  <p>The reason I want to be able to test purely from the JS side is so that we can test the systems independently of each other. I am aware I can test the full application with Behat, Mink and PhantomJS for example. </p>