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

@b4dnewz/express-test-server

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@b4dnewz/express-test-server

A minimal but customizable Express server for testing

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

express-test-server

A minimal but customizable Express server for testing

Typescript based preconfigured Express application intended for quick testing requests and responses, it can can be customized to listen for HTTP and HTTPS traffic and alter the default body parser behavior.

The following Content-Type headers will be parsed and exposed via req.body:

  • JSON (application/json)
  • Text (text/plain)
  • URL-Encoded (application/x-www-form-urlencoded)
  • Buffer (application/octet-stream)

Installation

npm install --save-dev @b4dnewz/express-test-server

Getting started

import createServer from "@b4dnewz/express-test-server"

const server = await createServer({
  // server options
});

// Express route handler
server.get('/foo', (req, res) => {
  res.send('bar');
});

// Express alternative route handlers
server.get('/bar', () => 'foo');
server.get('/baz', 'foo');

Perfect for testing


import createServer from "@b4dnewz/express-test-server"

let server;

beforeAll(async () => {
  server = await createServer();
});

afterAll(async () => {
  await server.close();
});

it("respond to get requests", async () => {
  sever.get("/foo", "bar")
  const {body} = await got(`${server.url}/foo`)
  expect(body).toEqual("bar")
})

License

MIT

Keywords

FAQs

Package last updated on 20 Jul 2019

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