Skip to content

Instantly share code, notes, and snippets.

@jgwhite
Last active August 29, 2015 14:06
Show Gist options
  • Save jgwhite/3743f5f6f74204122ec7 to your computer and use it in GitHub Desktop.
Save jgwhite/3743f5f6f74204122ec7 to your computer and use it in GitHub Desktop.
Report Ember.js routing errors in QUnit output
// By default errors thrown in route hooks log to the console.
// The router then gracefully transitions to the error substate.
// In tests we’d rather see these errors reported in QUnit’s output.
// Implementing this is easy and here’s how...
// In app/routes/application.js add:
export default Ember.Route.extend({
actions: {
error: function(error) {
if (Ember.onerror) {
// Pass the error to the global onerror handler
Ember.onerror(error);
}
// Allow the event to continue bubbling
return true;
}
}
});
// In tests/test-helper.js add:
Ember.onerror = function(error) {
QUnit.pushFailure(error.message, error.stack);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment