Socket
Socket
Sign inDemoInstall

express-recorder

Package Overview
Dependencies
73
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    express-recorder

Records your middleware and gives you a result you can assert


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Install size
1.03 MB
Created
Weekly downloads
 

Readme

Source

Express Recorder

This module will pass fakes to your middleware which you can assert.

Example

var recorder = require('express-recorder');

// Middleware 

var middleware = function (req, res, next) {
  res.locals.username = req.body.firstname + ' ' + res.locals.lastname;
  next();
};

// Setup state

var body = { firstname: 'Geert' };
var locals = { lastname: 'Pasteels' }; 

recorder(middleware, { body: body, locals: locals }, function (result) {

  result.eql({
    next: true,
    locals: { lastname: 'Pasteels', username: 'Geert Pasteels' }
  });

});

State options

  • body
  • locals
  • session
  • params
  • query
  • cookies
  • headers
  • request

The 'request' option is used to add properties to the request object.


recorder(middleware, { request: { missing: 'MIA' } }, function (result) {
  //assert
});

Result object

The result object has the following properties for asserting.

  • render
  • redirect
  • send
  • json
  • next
  • header
  • cookie
  • locals

It also has a handy eql method that shows the difference between the result object and your expected object.

Tests

make test

Keywords

FAQs

Last updated on 24 Jul 2012

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc