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": "",
    "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) {'/login')
            .end(function(err, res) {
                if(err) throw err;


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);



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


Check out this bug and fix at the very end:



All Articles