1.0.0 • Published 12 years ago

express-recorder v1.0.0

Weekly downloads
19
License
-
Repository
github
Last release
12 years ago

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
1.0.0

12 years ago

0.0.5

12 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago