title: Getting “App is not defined” in teardown while testing Ember.js (ember-cli) app
body: <p>I'm trying to test a simple ember-cli app (following @bcardarella Dockyard tutorial: <a href="http://reefpoints.dockyard.com/2014/05/09/building-an-ember-app-with-rails-part-3.html" rel="nofollow">http://reefpoints.dockyard.com/2014/05/09/building-an-ember-app-with-rails-part-3.html</a>)</p>
  
  <p>Here's my test:</p>
  
  <pre><code>import startApp from 'wallet2/tests/helpers/start-app';
  module('Integration - Landing Page', {
    setup: function() {
      var App;
      return App = startApp();
    },
    teardown: function() {
      return Ember.run(App, "destroy");
    }
  });
  
  test('Should ask me to log in', function() {
    return visit('/').then(function() {
      equal(find('h1#title').text(), 'Please login');
      return equal(find('form').length, 1);
    });
  });
  </code></pre>
  
  <p>The test works, but I get </p>
  
  <pre><code>3. Teardown failed on Should ask me to log in: App is not defined
  Source:     
      at Object.module.teardown (wallet2/tests/integration/landing-page-test.js:13:26)
      at Object.Test.teardown (http://localhost:4200/assets/qunit.js:228:35)
      at http://localhost:4200/assets/qunit.js:364:10
      at process (http://localhost:4200/assets/qunit.js:1453:24)
      at http://localhost:4200/assets/qunit.js:479:5
  </code></pre>
  
  <p>Here's my start-app.js</p>
  
  <pre><code>var Application = require('wallet2/app')['default'];
  var Router = require('wallet2/router')['default'];
  
  export default function startApp(attrs) {
    var App;
  
    var attributes = Ember.merge({
      // useful Test defaults
      rootElement: '#ember-testing',
      LOG_ACTIVE_GENERATION:false,
      LOG_VIEW_LOOKUPS: false
    }, attrs); // but you can override;
  
    Router.reopen({
      location: 'none'
    });
  
    Ember.run(function(){
      App = Application.create(attributes);
      App.setupForTesting();
      App.injectTestHelpers();
    });
  
    App.reset(); // this shouldn't be needed, i want to be able to "start an app at a specific URL"
  
    return App;
  }
  </code></pre>
  
  <p>This is driving me crazy since yesterday. Thanks for your help!</p>