سؤال

I'm trying to test my server with some code like so:

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()

The thing that the server is doing usually takes a few seconds, which is longer than the default timeout of 2000ms, so I call .timeout 10000. However, despite this, when I run the code I get:

1) POST /do/some/stuff/ should do this thing:
   Error: timeout of 2000ms exceeded

What do I need to do to increase this timeout?

هل كانت مفيدة؟

المحلول

Changing the timeout on your request object does not change anything to Mocha's default timeout. Doing this.timeout(10000) (whatever the CoffeeScript equivalent is) inside your test should take care of that.

نصائح أخرى

You can specify the timeout when running your test framework. For instance for mocha it would be like mocha -t 7000 . Alternatively, you can add a test with setTimeout just to create a delay (if the required delay is in between tests).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top