Running tests with TestSwarm

If you’ve gone through the Getting started and Loading your code tutorials, this article will show you how to run your tests using TestSwarm.

Setting up a TestSwarm server is beyond the scope of this documentation, consult the TestSwarm docs for how to do this. Once you’ve set the server up you should have a project name and auth token for submitting jobs.

A TestSwarm job is basically a list of URLs that reference test pages you want TestSwarm to run. Let’s say you want to submit the jstest example tests as a job, and the latest commit is b4e2c37. The following request submits a job called jstest commit b4e2c37 to run in all browsers, and has one test page called Tests that we’ve deployed to

$ curl -X POST \
       -d 'action=addjob' \
       -d 'authUsername=jstest' \
       -d 'authToken=52ec45981a3d27e7d835c07c5a9be3a5' \
       -d 'jobName=jstest%20commit%20b4e2c37' \
       -d 'runMax=5' \
       -d 'browserSets[]=all' \
       -d 'runNames[]=Tests' \
       -d 'runUrls[]'

The test page at must include the TestSwarm server’s inject script, which you can do by adding this to the end of the page’s <head> section:

  var inject = '' + new Date().getTime()
  document.write('<scr'+'ipt src="' + inject + '"></scr'+'ipt>')

Once you’ve done this, everything should just work. jstest should automatically enable the TestSwarm reporter and your test results should be logged correctly.