'jest supertest with express-session
I want to test my routes with jest but I don't know how to mock or simulate a session in my test to pass the first if line 2
app.get('/getMailSuiviList', (req, res) => {
if (req.session.infoUser != undefined) {
let mail = require('../models/M_Email')
mail.indexSuiviByDept(req.session.infoUser.deptID)
.then(dataMails => {
res.json(dataMails)
})
.catch(e => {
res.json('Erreur: ' + e)
})
} else {
req.session.error = 'Vous devez vous connecter'
res.redirect('/')
}
})
Can someone help me?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
