This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
Releases: HugoDF/mock-express-request-response
Releases · HugoDF/mock-express-request-response
Setup simple authentication application
Mock/stub Express request/response
mock-request-response add mock request/response with jest and sinon
Tests for a middleware that consumes headers
Adds tests for headerAuthMiddleware
.
An example of testing a middleware and of mocking .get('header-name')
on Express requests.
logout tests
Adds tests for logout
route handler.
Route resets contents of req.session.data
and 200s. Example of testing a write to a field on req
(or res
)
login tests
Adds tests for login
route handler.
Adds a body param for mockRequest
since login reads from the body (which is actually provided by the body-parser middleware).
checkAuth tests
Adds tests for checkAuth
route handler using previously defined mockRequest
and mockResponse
.
The route just reads from res.session.data
and depending on the contents of the session, 401s (session is empty/invalid) or 200s with part of the contents of it.