forwardemail / forwardemail/supertest
POST, Promise never resolves
- Dominant language
- JavaScript
- Stars
- 14.4k
- Forks
- 782
- PR merge metrics
- No merged PRs in 30d
Description
I am doing this unit test with supertest and chai and I do it in these two way
```
it("POST /novedades/api/postSolicitudVacaciones (servicio de guardar una solicitud de vacaciones) ", (done) => {
request(app)
.post("/novedades/api/postSolicitudVacaciones")
.send({
dtFechaInicio: "2021-07-30",
intNumeroDiasDisfrutar: 3,
intNumeroDiasCompensar: 0,
arrAprobadores: "scardonas@domain.com"
})
.set({ token: token, Accept: "application/json" })
.expect((res) => {
console.log(res)
expect(res.body).to.have.property("error", false);
})
.expect(200)
.end((err) => {
if (err) throw new Error(err)
})
})
```
```
it("POST /novedades/api/postSolicitudVacaciones (servicio de guardar una solicitud de vacaciones) ", async() => {
await agent
.post("/novedades/api/postSolicitudVacaciones")
.send({
dtFechaInicio: "2021-07-30",
intNumeroDiasDisfrutar: 3,
intNumeroDiasCompensar: 0,
arrAprobadores: "scardonas@domain.com"
})
.set({ token: token, Accept: "application/json" })
.expect("Content-Type", /json/)
.expect(200)
.then((err, res) => {
console.log(res.body);
expect(res.body).to.have.property("error", false);
})
});
```
And in both cases I always get the error 'Timeout of 2000ms exceeded. For async tests and hooks, ensure "done ()" is called; if returning a Promise, ensure it resolves. ' and the test performs the unit test well because he saves in BD
Contributor guide
Assessment
This issue has not been assessed yet.