   customizeRunner: (options) ->
     undefined
 
-  customizeProcessStdout: (options) -> 
+  customizeProcessStdout: (options) ->
     undefined
 
   customizeConsole: (options) ->


  runMocha: ->
    @page.evaluate @runner, @reporter
    @mochaStarted = @page.evaluate -> mocha?.phantomjs?.runner or false
    if @mochaStarted
      @mochaRunAt = new Date().getTime()
      @page.evaluate @customizeRunner, @customizeOptions()

    phantom.exit 1

  finish: ->
    phantom.exit @page.evaluate -> mochaPhantomJS.failures

  initPage: ->
    @page = webpage.create()
    @page.onConsoleMessage = (msg) -> console.log msg
    @page.onInitialized = =>
      @page.evaluate ->
        window.mochaPhantomJS =
          failures: 0
          ended: false
          started: false
          run: ->
            mochaPhantomJS.started = true

  loadPage: ->
    @page.open @url
