   injectJS: ->
     if @page.evaluate(-> window.mocha?)
       @page.injectJs 'mocha-phantomjs/core_extensions.js'
-      @page.evaluate ->
-        mocha.phantomjs =
-          failures: 0
-          ended: false
-          started: false
-          run: ->
-            mocha.phantomjs.started = true
       @page.evaluate @customizeProcessStdout, @customizeOptions()
       @page.evaluate @customizeConsole, @customizeOptions()
     else

      @fail "Failed to start mocha."

  waitForMocha: =>
    ended = @page.evaluate -> mocha.phantomjs?.ended
    if ended then @finish() else setTimeout @waitForMocha, 100

  waitForRunMocha: =>
    started = @page.evaluate -> mocha.phantomjs?.started
    if started then @runMocha() else setTimeout @waitForRunMocha, 100

  runner: (reporter) ->
    try
      mocha.setup reporter: reporter
      mocha.phantomjs.runner = mocha.run()
      if mocha.phantomjs.runner
        mocha.phantomjs.runner.on 'end', ->
          mocha.phantomjs.failures = @failures
          mocha.phantomjs.ended = true
    catch error
      false


  customizeRunner: (options) ->
    undefined

  customizeProcessStdout: (options) ->
    undefined

  customizeConsole: (options) ->
