I am writing the mocha unit test for the my express router.
I found that however I try to stub the middleware, it still execute the middleware code.
Here is my router &
This is likely because the stub happened after the module has been loaded already. You probably need to clear the cache first for your router file and then load it in again after the stubbing because es6 will cache the imported modules.