forwardemail / forwardemail/supertest

Express 4 routes with middleware gets 404

Open
#708 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
14.4k
Forks
782
PR merge metrics
No merged PRs in 30d

Description

Hi,

I have a problem with Express 4 protected routes, here is my route definition and test:

**Test:**

```
describe("POST /users/change-password", function() {
it("it should has status code 200", function(done) {
supertest(app)
.post("/users/change-password")
.set({ Authorization: 'bearer ' + token})
.send({
"password": "test1234",
"email": "testing+mocha@gmail.com"
})
.then((response) => {
expect(response.statusCode).toBe(200);
expect(response.type).toBe('application/json');
});
});
});
```

**Failing** route (404 error)

`router.post('/change-password', isLogged, UserController.changePassword);`

**Working** route

`router.post('/change-password', UserController.changePassword);`

Any idea how to solve this?

Thanks!

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.