test timeout value modifiable globally with TEST_TIMEOUT env variable

This commit is contained in:
Ricky Ng-Adam 2014-05-02 12:32:15 +08:00
parent 1345516117
commit 8fb28c5cfe
3 changed files with 8 additions and 4 deletions

View File

@ -35,5 +35,5 @@ test('uses password file when PGPASSFILE env variable is set', function() {
done();
pg.end();
}))
}, 15000));
}));
});

View File

@ -24,5 +24,5 @@ test('connection with config ssl = true', function() {
done();
pg.end();
}))
}, 15000));
}));
});

View File

@ -133,9 +133,13 @@ assert.lengthIs = function(actual, expectedLength) {
var expect = function(callback, timeout) {
var executed = false;
timeout = timeout || 5000;
timeout = timeout || parseInt(process.env.TEST_TIMEOUT) || 5000;
var id = setTimeout(function() {
assert.ok(executed, "Expected execution of function to be fired within " + timeout + ' milliseconds');
assert.ok(executed,
"Expected execution of function to be fired within " + timeout
+ " milliseconds " +
+ " (hint: export TEST_TIMEOUT=<timeout in milliseconds>"
+ " to change timeout globally)");
}, timeout)
if(callback.length < 3) {