   test = path.join __dirname, 'fixtures/mochacases', name
   return test
 
+# FIXME: move to protocol
 connectClient = (client, callback) ->
   onStatus = (status) =>
     return if not status.online # ignore, might get false before getting a true

  afterEach (done) ->
    if httpServer
      httpServer.close()
    if ru
      ru.disconnect done
    else
      done()


      mochacompat.setup options, (err, state, server) ->
        httpServer = server

        ru = new runner.Runner runtimeDefinition(options)
        runAllComponentTests ru, (err, state) ->
          return done err if err
          chai.expect(state).to.have.length 1
          cases = state[0].cases
          chai.expect(cases).to.have.length 1
          chai.expect(cases[0].passed, 'testcase did not pass').to.equal true
          done()

  describe 'running a failing test', ->
    testcase = null
    it 'should recorded 1 failed test', (done) ->
      options =
        files: [ testPath('bdd-simple-failing.coffee') ]
      mochacompat.setup options, (err, state, server) ->
        httpServer = server
        ru = new runner.Runner runtimeDefinition(options)
        runAllComponentTests ru, (err, state) ->
          return done err if err
          chai.expect(state).to.have.length 1
          cases = state[0].cases
          chai.expect(cases).to.have.length 1
          testcase = cases[0]
          chai.expect(testcase.passed, 'failing testcase passed').to.equal false
          done()
    it 'has error message of the Chai assertion', ->
      chai.expect(testcase?.error).to.contain 'expected 42 to equal 41'
