Socket
Socket
Sign inDemoInstall

middleware-tester

Package Overview
Dependencies
110
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    middleware-tester

Test your middleware with fake requests


Version published
Weekly downloads
10
decreased by-50%
Maintainers
2
Install size
3.38 MB
Created
Weekly downloads
 

Readme

Source

middleware tester

Test your middleware with fake requests.

example

Example using tap and flask-router-plus:

var mwtest = require('middleware-tester');
var t = require('blue-tape');
var router = require('flask-router-plus')();

router.get('/get', function(req, res) {
    res.answer(200, req.query);
});

router.post('/post', function(req, res) {
    res.answer(200, req.body);
});

var tester = mwtest(router.route);

t.test('get', function(t) {
    return tester.getJSON('/get', {a: 1, b:2}).then(res) {
        t.equals(res.body.a, 1);
        t.equals(res.body.b, 2);
    });
});


t.test('post', function(t) {
    return tester.postJSON('/post', {a: 1, b:2}).then(function(res) {
        t.equals(res.body.a, 1);
        t.equals(res.body.b, 2);
    });
});

api

TODO

Keywords

FAQs

Last updated on 29 Nov 2018

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