teddyzeenny / ember-mocha-adapter

A mocha adapter for ember-testing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tests failing randomly with async code

huguesdk opened this issue · comments

I have random failures as soon as a promise is used in the tested code.

I usually get this error:

Error: Assertion Failed: You cannot defer readiness since the `ready()` hook has already been called.

I’m assuming I must be doing something wrong, so I asked the question on StackOverflow, but didn’t get a correct answer yet.

Here is a JS Bin testcase. It contains 10 times the same test and usually fails (tested with Firefox and Chromium).

The same tests run fine with QUnit (maybe by chance :)): JS Bin testcase.

I tried wrapping the promise in an Ember.run() call and also not calling mocha.setup(), but it doesn’t solve the problem.

Also, the JS Bin testcase of the proposed answer on another related question on StackOverflow still fails for me with the same error message.

As the readme explains, if you call mocha.setup you cancel the adapter.

Here's the working Jsbin. You should not call mocha.setup and you had a few setup problems.

Here's how the test should actually be written: http://emberjs.jsbin.com/nusewoqi/12/edit

Thanks for your reply. Unfortunately, both those JS Bins still fail for me in Firefox :(.

$ -> mocha.run() seems to fix it in Firefox.

Wow! Indeed. To help future users, adding this explanation to the README could be useful: #19.

Thanks for your help.