Passport, mocha, super exploitation ECONNREFUSED
I am trying to test authentication with mocha, supertest and passport, but I am getting a denied error. I guess it has to do with how I start my application ...
var testUser = {
"email": "test@test.com",
"password": "test"
};
var app = require('../../server');
var request = require('superagent');
var user = request.agent(app);
describe('authentication api ', function() {
it('should login a user', function(done) {
user.post('/login')
.send(testUser)
.end(function(err, res) {
if(err) throw err;
done();
});
});
});
This user exists in my mongo database. In my server file, which is two levels higher:
module.exports = app.listen(port, function() {
console.log('app listening on port: ' + port);
});
+3
thebiglebowski11
source
to share
1 answer
This seems to have been fixed in March 2015. The Yeaf Dafmonk Angular Fullstack generator is still using the older version of supertest. I fixed this by opening my file package.json
and updating the supertest version from "~ 0.11.0" to "1.0.1". Then I ran: npm prune && npm install
ECONNREFUSED is gone.
Check out this bug and fix at the very end: https://github.com/visionmedia/superagent/issues/314
0
Gardner bickford
source
to share