My supertest / tape test file looks like this:
var test = require('tape');
var app = require('../../api');
var agent = require('supertest').agent
var supertestCompatibleServer = agent(app.callback());
test('GET /Campus.svc', function (t) {
supertestCompatibleServer
.get('/Campus.svc')
.expect(200)
.expect('Content-Type', /json/)
.end(function (err, res) {
t.ifError(err, 'No error');
t.end();
});
});
What could be causing the tests to hang and how can I fix it?
This turned out to be related to this issue: https://github.com/substack/tape/issues/216
In my case, the database connection via knex was still open, which was causing node process to finish. The solution was to explicitly call knex.destroy() in a teardown test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With