Last active
August 29, 2015 14:06
-
-
Save jgwhite/3743f5f6f74204122ec7 to your computer and use it in GitHub Desktop.
Report Ember.js routing errors in QUnit output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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