Skip to content

Commit

Permalink
fix: Make the Ember tests pass again
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlafroscia committed Jul 12, 2018
1 parent 7f76527 commit 68cb70d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 7 additions & 2 deletions addon/instance-initializers/new-relic.js
Expand Up @@ -17,7 +17,7 @@ export function initialize() {
return errorName === 'TransitionAborted';
}

function handleError(error) {
function handleError(error, shouldThrowError = true) {
if (mustIgnoreError(error)) {
return;
}
Expand All @@ -28,6 +28,11 @@ export function initialize() {
// Ignore
}

// Ensure we don't throw errors with `Logger.error`
if (Ember.testing && shouldThrowError) {
throw error;
}

console.error(error);
}

Expand All @@ -44,7 +49,7 @@ export function initialize() {
Ember.RSVP.on('error', handleError);

Ember.Logger.error = function(...messages) {
handleError(generateError(messages.join(' ')));
handleError(generateError(messages.join(' ')), false);
};
}

Expand Down
9 changes: 4 additions & 5 deletions tests/acceptance/new-relic-browser-test.js
Expand Up @@ -10,7 +10,7 @@ test('Loading New Relic Browser', function(assert) {
andThen(function() {
var newRelic = window.NREUM;

assert.expect(8);
assert.expect(9);

assert.ok(newRelic,
'The New Relic object (NREUM) should be added to the window');
Expand All @@ -22,7 +22,6 @@ test('Loading New Relic Browser', function(assert) {
caught by the extra Ember events like onerror */

window.NREUM.noticeError = function(error) {

assert.ok(true,
'noticeError should be called by Ember.onerror');

Expand All @@ -33,22 +32,22 @@ test('Loading New Relic Browser', function(assert) {
'noticeError should not be called by Ember.onerror on TransitionAborted errors.');
};

Ember.onerror(new Error('Awh crap'));
assert.throws(() => {
Ember.onerror(new Error('Awh crap'));
}, 'Awh crap');

const transitionError = new Error('Ember Transition Aborted Test');
transitionError.name = "TransitionAborted";
Ember.onerror(transitionError);

Ember.Logger.error('Whoops', 'We done messed up', {});

});
});

test('console.error from Ember.Logger.error correctly shows messages', function(assert) {
visit('/');

andThen(function() {

console.error = function (message) {
assert.strictEqual(
message.toString(),
Expand Down

0 comments on commit 68cb70d

Please sign in to comment.