2.0.0 • Published 4 years ago

http-test-servers v2.0.0

Weekly downloads
11
License
MIT
Repository
github
Last release
4 years ago

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

2.0.0

4 years ago

1.0.0

8 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.9

10 years ago

0.0.7

10 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago