emberjs/ember-mocha

why does removing setTimeout in adapter.exception combined with done produce expected behavior?

Opened this issue · 3 comments

Relates to emberjs/ember.js#15013. The setTimeout found here https://github.com/emberjs/ember-mocha/blob/master/build-support/ember-mocha-adapter.js#L33-L36 causes erratic behavior and could be aggravating the underlying Ember bug.
Here is a reproduction repo: https://github.com/efx/run-loop-error-assertion-case.git

  1. clone the above repo, run npm install
  2. run ember test and see both tests failing
  3. run curl https://raw.githubusercontent.com/efx/ember-mocha/topic-bug/build-support/ember-mocha-adapter.js > node_modules/ember-mocha/build-support/ember-mocha-adapter.js
  4. run ember test again and see the test with done succeeds

Do you understand why including the done causes the test to behave as expected? Is this because done will trigger the test being wrapped in the run loop? I would like to rule out how ember-mocha may be affecting the above linked issue.

@efx I do not think that this is something that ember-mocha should support. If Ember decides to no longer throw exceptions from a function and instead expose them somewhere else then there is not much here that we can do without it getting messy really fast.

the done test is likely succeeding because it's not actually testing anything... done should be avoided at all costs now that we have Promise support in Mocha.

The first part makes sense to me; I was really curious as to why the adapter has that setTimeout as it seems to be a work around for how Ember executes the tests. That's good to know about avoiding done.

it seems to be a work around for how Ember executes the tests

yeah, that is some funky business going on to support the implicitly async acceptance tests using andThen() and friends. that btw is also the reason why we haven't been able to upgrade to Mocha 3 yet...