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

artificial

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

artificial

Inject fake HTTP request/response into an Express server

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

artificial

Current Version Build Status via Travis CI Dependencies belly-button-style

Inject fake HTTP request/response into an Express server. This is a port of hapi's shot module, adapted to work with Express. artificial allows fake responses to be injected into a server without first binding to a port. This simplifies testing.

Basic Usage

'use strict';
const Artificial = require('artificial');
const Express = require('express');
const app = Express();

Artificial(app);  // Create the app.inject() method.

app.get('/', (req, res, next) => {
  res.send({ success: 'success!' });
});

app.inject({ method: 'GET', url: '/' }, (res) => {
  // res contains the fake HTTP response.
});

API

artificial exports a single function that is used to add a single injection method to an Express app.

Artificial(app [, method])

  • Arguments
    • app (object) - An Express application.
    • method (string) - The name of the method to attach to app. Optional. Defaults to 'inject', meaning that app.inject() is created.
  • Returns
    • app (object) - The same Express application as app.

Defines an injection method on an Express server. By default, the method's name is inject(). This method injects a request into the server, simulating an incoming HTTP request without using sockets. Injection is useful for testing purposes, as well as for invoking routing logic internally without the overhead and limitations of the network stack.

Keywords

FAQs

Package last updated on 04 Jan 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