title: Better way to integrate maven/qunit/phantomjs?
body: <p>I have been investigating the best way to do JS unit testing in our maven CI environment. What I currently have cobbled together is the following in my maven project:</p>
  
  <ul>
  <li>qunit resources (JS/CSS files)</li>
  <li>qunit test html files (one for each file under test) with html fixture if required</li>
  <li>index html file which references the test html files as an ordered list of hyperlinks</li>
  <li>PhantomJS runner file, which:
  <ul>
  <li>opens the index html file and parses out list of test files</li>
  <li>opens each test file</li>
  <li>takes a screenshot of the qunit test results for each file</li>
  <li>If there are any failures, exit with a status of "1"</li>
  <li>If there are no failures, exit with a status of "0"</li>
  </ul></li>
  <li>shell file which will exit with "0" if phantomjs isn't installed, will call the phantomjs tests if it is installed</li>
  <li><p>changes to pom.xml to run phantomjs tests during test phase of build:</p>
  
  <pre><code>&lt;plugins&gt;
      &lt;plugin&gt;
          &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
          &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
          &lt;version&gt;1.1&lt;/version&gt;
          &lt;executions&gt;
              &lt;execution&gt;
                  &lt;id&gt;PhantomJS Unit Testing&lt;/id&gt;
                  &lt;phase&gt;test&lt;/phase&gt;
                  &lt;goals&gt;
                      &lt;goal&gt;exec&lt;/goal&gt;
                  &lt;/goals&gt;
              &lt;/execution&gt;
          &lt;/executions&gt;
          &lt;configuration&gt;
              &lt;executable&gt;${project.basedir}/src/main/webapp/unittest/phantomcheck&lt;/executable&gt;
              &lt;arguments&gt;
                  &lt;argument&gt;${project.basedir}/src/main/webapp/unittest/qunit-runner.js&lt;/argument&gt;
                  &lt;argument&gt;${project.basedir}/src/main/webapp/unittest/tests/index.html&lt;/argument&gt;
                  &lt;argument&gt;${project.build.directory}/surefire-reports&lt;/argument&gt;
              &lt;/arguments&gt;
          &lt;/configuration&gt;
      &lt;/plugin&gt;
  &lt;/plugins&gt;
  </code></pre></li>
  </ul>
  
  <p>So, this works nicely. It runs the qunit tests during builds on our dev and build machines (as long as PhantomJS is installed). The tests run in a headless browser environment with no restrictions on the qunit tests. Other maven/qunit integrations I've seen fall short due to running the tests in Rhino, or other JS environments which place restrictions on the type of tests we can write. Plus phantomjs gives us the ability to have the screenshots of the test runs, which are helpful in troubleshooting any failures.</p>
  
  <p>The drawback to my approach is that a PhantomJS installation is required on the build/dev machine. I don't know how to bundle phantomJS into a dependency such that developers don't need to worry about installing PhantomJS. Can anyone give me a push in this direction? How do I get started?</p>