reqres
Stub request and response objects for testing express applications and middleware
Creates default request and response object with configurable values, and methods stubbed with sinon.stub.
Usage
Using default request properties:
const middleware = { reqsessionpath = reqpath;};const reqres = ; ;
const router = ;router ;const reqres = ; ;
All methods which would normally send a response (and so end the middleware chain) e.g. json
, send
will emit an "end" event, so this can be bound onto for running assertions.
const router = ;router ;const reqres = ; ;
Customisation
If you want to use a different version of sinon to that which is included in reqres - or indeed a completely different stub/spy library - then you can set the sinon property to your own local version.
const reqres = ;reqressinon = ;