# express-recorder

> Records your middleware and gives you a result you can assert

Latest version **1.0.0** (published 2012-07-24) · 0 weekly downloads

## Install

```sh
npm install express-recorder
pnpm add express-recorder
yarn add express-recorder
bun add express-recorder
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2012-07-24 |
| First published | 2012-03-13 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Geert Pasteels |
| Maintainers | enome |
| Keywords | express, testing, middleware, routes |

## Links

- npm: https://www.npmjs.com/package/express-recorder
- Repository: https://github.com/Enome/express-recorder
- npm.io page: https://npm.io/package/express-recorder

## Dependencies (3)

- [eql](https://npm.io/package/eql.md) 0.0.5
- [difflet](https://npm.io/package/difflet.md) *
- [underscore](https://npm.io/package/underscore.md) *

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2012-07-24
- 0.0.5 — 2012-07-07
- 0.0.4 — 2012-07-07
- 0.0.3 — 2012-05-18
- 0.0.2 — 2012-05-13
- 0.0.1 — 2012-03-13

## README

# Express Recorder

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

## Example

```js
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.

```js

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

```sh
make test
```

---
_Source: https://npm.io/package/express-recorder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
