yui/yeti — pull request #75 by alex-seville (2014-02-03 02:48:47+00:00)
Title: Allow deferred initialization of mocha test runner via a flag

This addresses the following issues:
* https://github.com/yui/yeti/issues/60
* http://yuilibrary.com/forum/viewtopic.php?p=39725

Because mocha needs to be initialized (`mocha.run()`) in order to return a reference to the runner (need by Yeti to bind events), any tests that use a deferred initialization of mocha (via `requirejs.require`, `YUI.use`, or other means) will not be run correctly.

This PR addresses the issue by allowing the user to include a `asyncYeti` flag in their tests (ignored if not running Yeti). This flag will alert Yeti to wait until the test runner defer-redly calls `mocha.run()` before initializing mocha.

It's less than ideal because it requires the creation of the flag variables, and because it overrides `mocha.run` temporarily. However, I think these tradeoff are fair given that it works and unblocks users who are unable to use Yeti because they have deferred mocha initializations.

Mocha may or may not be updated in the future (https://github.com/visionmedia/mocha/pull/719), so I think leaving the Yeti binding patterns in place is better than trying to over-engineer a solution to this problem.

Let me know what you think!