workmanw / ember-qunit-assert-helpers

An ember-addon that provides additional QUnit 2.0 assertions specific to Ember.js.
MIT License
13 stars 9 forks source link

Improved the implementation of `expectAssertion` #6

Closed workmanw closed 7 years ago

workmanw commented 7 years ago

This is to handle assertions thrown inside of a runloop during an integration test. Related to: https://github.com/emberjs/ember.js/pull/14898 .

rwjblue commented 7 years ago

I have thoughts...

I'd prefer to avoid clobbering Ember.Test.adapter, lets make ember-qunit expose an override to make this a bit simpler?

rwjblue commented 7 years ago

so we could do:

import { setAdapterExceptionHandler } from 'ember-qunit';

// ... snip ...

QUnit.assert.expectAssertion = function() {
   let lastError;
   setAdapterExceptionHandler((error) => lastError = error);
   // snip rest of code
};
rwjblue commented 7 years ago

@workmanw - Thoughts?

workmanw commented 7 years ago

@rwjblue Yea, that works for me. We also need a way to remove or reset that exception handlers? I'd be happy to submit a PR to ember-qunit.

EDIT: Actually I guess we could just do setAdapterExceptionHandler(null); to reset it.

rwjblue commented 7 years ago

I was thinking null for reset, yes

workmanw commented 7 years ago

@rwjblue Do you have any objection to me cutting a release with this PR. Then immediately working on setAdapterExceptionHandler? I'm looking to provide relief for the issue discussed in: https://github.com/emberjs/ember.js/pull/14898

rwjblue commented 7 years ago

nope, no objections. The thing I'm suggesting above is really just another iteration forward...

workmanw commented 7 years ago

Excellent. Thanks for the feedback and direction. I'll submit PRs to make this happen.