设置超时,超时无效

lim*_*imp 4 mocha.js node.js supertest

我正试图用一些代码来测试我的服务器:

describe 'POST /do/some/stuff/', ->
  it 'should do this thing', (done) ->
    request app
      .post '/do/some/stuff/'
      .timeout 10000
      .expect 200
      .end (err, res) ->
        return done err if err?
        done()
Run Code Online (Sandbox Code Playgroud)

服务器正在做的事情通常需要几秒钟,这比默认超时2000毫秒长,所以我打电话.timeout 10000.但是,尽管如此,当我运行代码时,我得到:

1) POST /do/some/stuff/ should do this thing:
   Error: timeout of 2000ms exceeded
Run Code Online (Sandbox Code Playgroud)

我需要做些什么来增加此超时?

Lou*_*uis 10

更改request对象的超时不会改变Mocha的默认超时.this.timeout(10000)在测试中做(无论CoffeeScript等价物是什么)应该照顾它.