Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting timeouts with supertest not working

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?

like image 658
limp_chimp Avatar asked Dec 26 '22 09:12

limp_chimp


1 Answers

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.

like image 97
Louis Avatar answered Dec 28 '22 11:12

Louis