Question restated:
How can we dynamically trigger, run, and get results back from CasperJS/PhantomJS tests via a web-app running NodeJS/Express/AngularJS?
Background and investigation:
Let me preface this question by saying that I understand there have been similar questions asked around this, which I have tried at length to do my due diligence on reading / understanding.
I believe my question is a little different because I understand that PhantomJS and NodeJS do not inherently work together due to a variety of reasons. There have been various projects that have attempted to "bridge" between NodeJS and PhantomJS. The one that always comes up is phantomjs-node.
However, as the author of that app points out there are a myriad of issues and the chief dev (I believe) of PhantomJS has indicated that they will not support NodeJS.
Got it. However, there are lots of test runners out there that seem to offer NodeJS integration and leverage PhantomJS. GruntJS for example, can leverage MochaJS tests, which in-turn can call JasmineJS, which apparently can be leveraged via PhantomJS.
Challenge/Differentiators
I don't want to test MY webapp and that seems to be the only use-case most tutorials and questions revolve around in the community. My use-case is testing other sites, already live for proper integration of a web app.
To that end I have a whole NodeJS / Express / AngularJS application that is a web-based test and reporting suite and I want to integrate the CasperJS / PhantomJS test results. I want to be able to dynamically pass a URL from my AngularJS front-end to my NodeJS / Express server, which will then trigger my CasperJS/PhantomJS tests and return the results in a fashion that I can include in my AngularJS reporting front-end.
Potential solution through calling separate process from NodeJS
I have seen reference, though I cannot find it now, of calling a "command" to generate a separate process to run PhantomJS from NodeJS. Is this the best way to accomplish my goals (I do not want to use one of the NodeJS / PhantomJS bridges if possible, tell me if I'm being too closed minded)?
Potential solution through Mocha visionmedia.github.io/mocha/
I have looked at Mocha and it appears promising, with their tagline being, "Mocha is a feature-rich JavaScript test framework running on node.js and the browser." However, they don't provide any examples of pluming those tests into a dynamic web-app like mine. They always come from the stance of assuming you are testing your app and you will be running a series of tests outside of your app instead of from within your app, as I intend to do.
This part looks particularly promising with Mocha Browser Support. It appears I could potentially use this in my front-end to trigger my Mocha tests, right?
Thanks for all your help in advance! I'm pretty new to testing so my head is swimming some here.
[EDIT] Related question(s), which do not 100% answer my question
Is it possible to run PhantomJS from node.js as a command line argument