metaskills/mocha-phantomjs — pull request #13 by jeffbski (2012-10-11 18:31:59+00:00)
Title: revise mochaPhantomJS inject and run until after callPhantom

Change initialization procedure such that instead of injecting the core extensions
immediately after page load and then loop watching for
window.mochaPhantomJS.started

Instead, start the initialize on mochaPhantomJS.run().
This uses window.callPhantom('mochaPhantomJS.run')
as the trigger to begin augmenting and running.
(so it requires phantomJS 1.6+, current version is 1.7)

In this way, mocha is fully loaded and mochaPhantomJS is ready to be overlayed
(process.stdout exists, ...) and then we can immediately start the run.

I had to add mochaPhantomJS.run() to the blank page test HTML
since it won't even start the initialization and check process unless
this is called.

I tried to make the minimum changes to get this working, you could
rework the @waitForRunMocha now since it doesn't really need a loop,
we know that when called, mocha has been loaded.