PhantomJS 1.6+ has a callback API that might be useful to replace the alert-json-tmp-file hackity hack. QUnit's phantomjs now makes use of that, maybe that's useful as a reference: https://github.com/jquery/qunit/blob/0552f0d8ae1a43fcfa0bbee17dc958fef2d29e0d/addons/phantomjs/runner.js#L115
PhantomJS 1.6+ has a callback API that might be useful to replace the alert-json-tmp-file hackity hack. QUnit's phantomjs now makes use of that, maybe that's useful as a reference: https://github.com/jquery/qunit/blob/0552f0d8ae1a43fcfa0bbee17dc958fef2d29e0d/addons/phantomjs/runner.js#L115