     chromedriver.stderr.on "data", (log) ->
       logs.push(log.toString())
     chromedriver.stderr.on "close", ->
-      if errorCode?
-        reject("Chromedriver failed. Code: #{errorCode}. Logs: #{logs.join("\n")}")
-      else
-        resolve()
+      resolve({errorCode, logs})
 
   waitsFor("webdriver to finish", (done) ->
     finish = once ->

    "--url-base=/wd/hub"
  ])

  chromedriverExit = new Promise (resolve, reject) ->
    errorCode = null
    logs = []
    chromedriver.on "exit", (code, signal) ->

        .end()
        .then(-> chromedriver.kill())
        .then(chromedriverExit.then(
          ({errorCode, logs}) ->
            if errorCode?
              jasmine.getEnv().currentSpec.fail """
                Chromedriver exited with code #{errorCode}.
                Logs:\n#{logs.join("\n")}
              """
            done()))

    client = buildAtomClient(args, env)

    client.on "error", ({body}) ->
      jasmine.getEnv().currentSpec.fail(body)
      finish()

    fn(client.init()).then(finish)
