Application#reset()

resetpublic

Defined in packages/ember-application/lib/system/application.js:609

Reset the application. This is typically used only in tests. It cleans up the application in the following order:

  1. Deactivate existing routes
  2. Destroy all objects in the container
  3. Create a new application container
  4. Re-route to the existing url

Typical Example:

let App;

run(function() {
  App = Ember.Application.create();
});

module('acceptance test', {
  setup: function() {
    App.reset();
  }
});

test('first test', function() {
  // App is freshly reset
});

test('second test', function() {
  // App is again freshly reset
});

Advanced Example:

Occasionally you may want to prevent the app from initializing during setup. This could enable extra configuration, or enable asserting prior to the app becoming ready.

let App;

run(function() {
  App = Ember.Application.create();
});

module('acceptance test', {
  setup: function() {
    run(function() {
      App.reset();
      App.deferReadiness();
    });
  }
});

test('first test', function() {
  ok(true, 'something before app is initialized');

  run(function() {
    App.advanceReadiness();
  });

  ok(true, 'something after app is initialized');
});
doc_EmberJs
2016-11-30 16:48:27
Comments
Leave a Comment

Please login to continue.