Skip to content

Instantly share code, notes, and snippets.

@maxcnunes
Created December 24, 2013 12:55
Show Gist options
  • Save maxcnunes/8112950 to your computer and use it in GitHub Desktop.
Save maxcnunes/8112950 to your computer and use it in GitHub Desktop.
Wait mongo connection before test express controller/route with supertest
var request = require('supertest'),
mongoose = require('mongoose'),
app = require('../../../../server');
describe('GET /api/transactions/import', function(){
before(function (done) {
mongoose.connection.on('open', done);
});
it('respond with json', function(done){
request(app)
.get('/api/transactions/import')
.expect(200)
.end(function(err, res){
if (err) return done(err);
done();
});
});
});
before(function (done) {
mongoose.connection.on('open', done);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment