mochajs / mocha

☕️ simple, flexible, fun javascript test framework for node.js & the browser
https://mochajs.org
MIT License
22.59k stars 3.01k forks source link

Error: timeout of 2000ms exceeded #474

Closed angelochen960 closed 12 years ago

angelochen960 commented 12 years ago

https1.js:

var https = require('https');

var options = {
  host: 'secure-test.worldpay.com',  port: 443,
  path: '/jsp/merchant/xml/paymentService.jsp',
  method: 'POST'
};

exports.post_proc = function (json, cb) {

    var req = https.request(options, cb)
    req.end("test")
    req.on('error', function(e) {
  console.error(e); 
});

} 

https2.js:

https1 = require("./https1")

// this part works if runs : node https2 */
/*
https1.post_proc(null, function(res) {
    console.log('back')
    console.log('STATUS: ' + res.statusCode);
  console.log('HEADERS: ' + JSON.stringify(res.headers));
  res.on('data', function (chunk) {
    console.log('BODY: ' + chunk);
  });
}) 
*/

describe('test https1', function () {
    describe('#https1', function () {
        it('should return response object', function (done) {

            https1.post_proc(null, function (res) {
                res.setEncoding('utf8');
                res.on('data', function (chunk) {
                    console.log('BODY: ' + chunk);
                    done()
                });
            })
        })
    })
}) 

got error:

1) test https1 #https1 should return response object: Error: timeout of 2000ms exceeded at Object. (/usr/local/lib/node_modules/mocha/lib/runnable.js:126:14) at Timer.ontimeout (timers.js:84:39)

mocha --version 1.2.0

paulmillr commented 12 years ago

did you use option --timeout?

vduggirala commented 10 years ago

Hey i am also getting exactly same error, Any help on this topic. i tried setting timeout using req.setTimeout(30000, function(err){}); not sure where to use --timeout in options do we have timeout key in options json?

hacksparrow commented 10 years ago

@vduggirala $ mocha test.js --timeout 30000