Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-test-servers

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-test-servers

Speeds up some http servers on localhost to facilitate acceptance tests of applications that require api interactions

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7K
increased by842.22%
Maintainers
1
Weekly downloads
 
Created
Source

http-test-servers Build Status

NPM

Speeds up some http servers for testing pourposes.

Installation

  npm http-test-servers

Sample usage (init, start, kill)

  // Routes first. They can be a simple string (will be a get route), or objects as follows

  var routes = {
    route1: '/getData',
    route2: {
      route: '/postData2',
      method: 'post',
      statusCode: 302,
      response: { 'hello': 'world' }
    }
  };

  // Next the servers. The optional delay is to simulate a delay on the response. For each one the same routes will be created

  var servers = {
    server1: {
      port: 3006
    },
    server2: {
      port: 3007,
      delay: 2000
    }
  };

  // Optional: the options. 

  var options = { logger: true };

  // init
  var testServers = new TestServers(routes, servers, options);

  // start them
  testServers.start(function(testServers){

    // if you want, take a look at this
    console.log(testServers)

    // don't forget to kill them
    testServers.kill(function(){
      
      console.log('killed everything');
    });
  });

Options

logger

(Boolean): Displays some info on the console every time a request is made

Tests

  npm test

License

MIT

Bitdeli Badge

Keywords

FAQs

Package last updated on 24 Oct 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc