Authentication Mocha/Chai登录方法单元测试节点JS

Authentication Mocha/Chai登录方法单元测试节点JS,authentication,testing,mocha.js,chai,Authentication,Testing,Mocha.js,Chai,我已经对用户CRUD和注册用户进行了测试,一切都很顺利。但是对于登录测试,我得到了一个未定义的响应,即使使用调试器,我也无法判断我缺少了什么。看起来它没有保存新创建的用户。还尝试使用post方法创建用户,然后检查登录方法。在《邮递员》中,路线运行得非常好 it("should login an existing user and return a token", (done) => { let user = new User({

我已经对用户CRUD和注册用户进行了测试,一切都很顺利。但是对于登录测试,我得到了一个未定义的响应,即使使用调试器,我也无法判断我缺少了什么。看起来它没有保存新创建的用户。还尝试使用post方法创建用户,然后检查登录方法。在《邮递员》中,路线运行得非常好

        it("should login an existing user and return a token", (done) => {
            let user = new User({
            username: "userTest112", 
            firstName: "User", 
            lastName: "Test",
            email: "userLogin@test.com", 
            password: "password", 
            userType: "participant",
            job: {
                employStatus: "employed",
                studentStatus: false
            }
            })
            user.save(() => {
                chai.request(server)
                .post("api/auth/login")
                .send ({
                    email: "userLogin@test.com",
                    password: "password"
                })
                .end((err, res) => {
                    console.log(err);
                    res.should.have.status(200);
                    res.body.should.be.a("object");
                    res.body.token.should.not.be.empty;
                    done();

                })
            })
        })
    }) ```
Error: connect ECONNREFUSED 127.0.0.1:80
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1129:14) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 80,
  response: undefined
}
似乎在路径中忘记了一个“/”