-
|
Hi, In a Node.js application using Express 4, I introduced a new custom middleware for handling user authentication. The middleware, called router.get("/:clientId", authClient, async (req: Request, res: Response) => {
...
}However, when running integration tests, all tests related to testing the absence of path parameters, even in other request handlers attached to the same router, fail because they called Does anyone have any idea why? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Someone found the solution for me. Actually, the requests sent by the failing tests, even though they were supposed to test other request handlers, were already caught and processed by The solution was to move the |
Beta Was this translation helpful? Give feedback.
Someone found the solution for me.
Actually, the requests sent by the failing tests, even though they were supposed to test other request handlers, were already caught and processed by
router.get("/:clientId", ...by mistake, even before I introduced the newauthClientmiddleware. This was due torouter.get("/:clientId", ...located at the beginning of the source code file, before the other router's request handlers.The solution was to move the
router.get("/:clientId", ...request handler to the bottom of the source code file, and to turn mandatory path parameters into optional ones to make sure they still get caught by the right request handlers.