sinon
is being used to mock methods in tests. It is one of the most used package for testing. But Is there a way to mock session objects in tests for express?
I'm working on a project where I upload images to s3 in bulk (albums) and than further apply some processing like resizing/compression/editing on them.
It's a express app with middlewares for authorization, authentication, setting context and is working fine.
Recently I started adding testcases for different routes using mocha
. I'm using cookie-session
for session handling in app.
For one route, I needed to mock req.session
object. (Need to set it's value before calling the other route.)