forwardemail / forwardemail/supertest

POST, Promise never resolves

Open
#727 7 comments 1 reaction 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.