I'm presently using mocha 2.5.3, supertest 2.0.0, knex 0.11.10, restify 4.1.1 and sqlite3 3.1.4.
I have the following very simple restify server:
const restify = require('restify');
const knex = require('knex')({
client: 'sqlite3',
connection: {
'filename': 'test.db'
}
});
const app = restify.createServer();
app.get('/', (req, res, next) => {
knex.select().from('nonexistent_table')
.then((rows) => {
return res.json(rows);
})
.catch((err) => {
return res.send('error');
});
});
module.exports = app;
The below test will cause the test to timeout at 2000ms instead of failing:
const assert = require('assert');
const supertest = require('supertest');
const app = require('./app');
describe('GET /', function () {
it('should not timeout', function (done) {
supertest(app)
.get('/')
.end(function(err, res) {
assert(false);
done();
});
});
});
If the call to knex is fulfilled instead of being rejected, the test fails properly and does not timeout. The timeout appears to occur only if the knex call is rejected.
Does anyone have thoughts on what could be causing the timeout instead of a proper failure?
EDIT: I've debugged this as far as I could, and it seems the timeout happens when mocha tries to generate a stacktrace.