Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghost opened this issue May 23, 2017 · 3 comments

Comments

@ghost
Copy link

ghost commented May 23, 2017

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.

@Turbo87
Copy link
Member

Turbo87 commented May 26, 2017

@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.

@Turbo87 Turbo87 closed this as completed May 26, 2017
@ghost
Copy link
Author

ghost commented May 26, 2017

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.

@Turbo87
Copy link
Member

Turbo87 commented May 26, 2017

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant