Mock Express request and response - Code with Hugo - Feb 18th 2019
Hot off the press
A guide to Express request and response mocking/stubbing with Jest or sinon: how to test Express handlers and middleware by calling them up with a mock request and reponse object built using Jest mocks or sinon to stub.
It’s the alternative way to unit test Express route handlers to “Testing an Express app with SuperTest, moxios and Jest”.
You can see the repo at github.com/HugoDF/mock-express-request-response.
The example used is a pretty true to life session management section of an application’s authentication system (bar the “not connected to a database” bit).
If you missed it
12-factor Node.js application configuration management without the config npm package: Node.js config management done right and my issues with theconfig
npm package in the context of trying to keep your application 12-factor
A tiny case study about migrating to Netlify when disaster strikes at GitHub, featuring Cloudflare: Still loving my life on Netlify, a write-up of how it came to be.
Mocking/stubbing ES6 classes in tests with examples of Sequelize model unit.
From the web
Help! None of my projects want to be SPAs
Future JavaScript: what is still missing?: Excellent write-up (as always) by Axel Rauschmayer of JavaScript features still in the pipeline.
How to start a Node.js project: used a couple of the commands in here to boostrap this week’s demo project.
If you’re still here, feel free to head over to codewithhugo.com and have a browse or hit me up on Twitter @hugo__df.