Testing Ember.Logger.error assertions


#1

I’m using Ember.Logger.error:

if (isInvalid) {
  Ember.Logger.error('this is invalid');
}

I want to test it in qunit:

assert.throws(() => myFunction(), /this is invalid/, 'error was thrown');

But assert.throws doesn’t catch the error. It does if I replace Ember.Logger.error with a simple throw statement, but surely there’s a way to test for logged Ember errors. Anyone know the way?


#2

I made a little addon for this. If you’re interested, you’ll find it here.