Created
December 24, 2013 12:55
-
-
Save maxclaus/8112950 to your computer and use it in GitHub Desktop.
Wait mongo connection before test express controller/route with supertest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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