
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
hof-util-reqres
Advanced tools
Test helper to create dummy request/response objects for testing middleware methods
Test helper to create dummy request/response objects for testing middleware methods
In your tests you can use the provided req and res methods to create objects with additional properties that we would expect to exist on a request that had passed through a hof request pipeline.
const request = require('hof-util-reqres').req;
const req = request();
it('provides a sessionModel property on the request', () => {
expect(req.sessionModel).to.be.an.instanceOf(require('hof-model'));
});
it('provides a translate property on the request', () => {
expect(req.translate).to.be.a('function');
});
it('provides a form property on the request with values', () => {
expect(req.form).to.eql({ values: {} });
});
Additionally, the request and response objects will have all properties and methods exposed by express. Response methods will be instances of sinon stubs, and so can have assertions made against their calls.
See reqres module for further details of default express behaviour.
The session model can be pre-populated by passing a session option.
const request = require('hof-util-reqres').req;
const req = request({
session: { name: 'Alice' }
});
it('populates session model with `session` parameter', () => {
expect(req.sessionModel.get('name')).to.equal('Alice');
});
FAQs
Test helper to create dummy request/response objects for testing middleware methods
We found that hof-util-reqres demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.