   console.log(desired)
   browser.init desired, (err) ->
     assert.ifError(err)
-    test ->
+    test 'http://localhost:' + port, ->
       browser.quit()
       server.close()
       tunnel.stop ->
-        console.log(chalk.green('Cleaned up.'))
+        console.log(chalk.green('Tunnel stopped, cleaned up.'))

assert = require('assert')
chalk = require('chalk')

sauceUser = process.env.SAUCE_USERNAME || 'mathdown'
# I hope storing this in a public test is OK given that an Open Sauce account
# is free anyway.  Can always revoke if needed...

# TODO: Cleanup even if there were errors.  Use promises for sanity?
#  Use a test runner with guaranteed pre/post methods?

test = (url, cb) ->
  # Kludge: set to failed first, change to passed if we get to the end without crashing.
  browser.sauceJobStatus false, ->
    browser.get url + '?doc=_mathdown_test_smoke', (err) ->
      assert.ifError(err)
      browser.waitFor wd.asserters.jsCondition('document.title.match(/smoke test/)'), 10000, (err, value) ->
        assert.ifError(err)
