以下代码适用于我朋友的计算机,但不适用于我的计算机。有谁知道为什么????
const request = require('supertest')
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
const passport = require('passport')
const LocalStrategy = require('passport-local').Strategy
passport.use(new LocalStrategy(
(username, password, done) => {
console.log('Verify Called')
done()
}
))
app.use(bodyParser())
app.use(passport.initialize())
app.use(passport.session())
app.post('/login', passport.authenticate('local'), (req, res) => {
console.log('Login route hit')
})
const server = app.listen(3000)
describe('Routes', () => {
it('Responses from /login contain a cookie', () => {
request(server)
.post('/login')
.type('form')
.send({username: 'srpalo'})
.send({password: 'secretpassword'})
})
})
任何帮助将不胜感激!!我一直坚持这个问题整整一天。