# shot

> Injects a fake HTTP request/response into a node HTTP server

Latest version **4.0.7** (published 2018-11-03) · BSD-3-Clause license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install shot
pnpm add shot
yarn add shot
bun add shot
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.0.7 |
| Published | 2018-11-03 |
| First published | 2012-09-17 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | separate (@types/shot) |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 12.8 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 196 |
| Maintainers | hueniverse, marsup, mtharrison, nlf, wyatt |
| Keywords | utilities, http, debug, test |

## Links

- npm: https://www.npmjs.com/package/shot
- Repository: https://github.com/hapijs/shot
- Homepage: https://github.com/hapijs/shot#readme
- Issues: https://github.com/hapijs/shot/issues
- npm.io page: https://npm.io/package/shot

## Dependencies (2)

- [joi](https://npm.io/package/joi.md) 14.x.x
- [hoek](https://npm.io/package/hoek.md) 6.x.x

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 4.0.7 (latest) — 2018-11-03
- 3.5.2 (v3-legacy) — 2024-01-06
- 4.0.6 — 2018-11-01
- 4.0.5 — 2018-02-15
- 4.0.4 — 2017-11-14
- 4.0.3 — 2017-10-22
- 4.0.2 — 2017-10-04
- 4.0.1 — 2017-09-28
- 4.0.0 — 2017-09-23
- 3.4.2 — 2017-06-01
- 3.4.1 — 2017-06-01
- 3.4.0 — 2016-11-29
- 3.3.2 — 2016-09-09
- 3.3.1 — 2016-08-26
- 3.3.0 — 2016-08-26
- … 53 more at https://npm.io/package/shot/versions

## README

![shot Logo](https://raw.github.com/hapijs/shot/master/images/shot.png)

Injects a fake HTTP request/response into a node HTTP server for simulating server logic, writing tests, or debugging. Does not use a socket
connection so can be run against an inactive server (server not in listen mode).

[![Build Status](https://secure.travis-ci.org/hapijs/shot.png)](http://travis-ci.org/hapijs/shot)

Lead Maintainer: [Matt Harrison](https://github.com/mtharrison)

## Example

```javascript
// Load modules

const Http = require('http');
const Shot = require('shot');


// Declare internals

const internals = {};


internals.main = async function () {

    const dispatch = function (req, res) {

        const reply = 'Hello World';
        res.writeHead(200, { 'Content-Type': 'text/plain', 'Content-Length': reply.length });
        res.end(reply);
    };

    const server = Http.createServer(dispatch);

    const res = await Shot.inject(dispatch, { method: 'get', url: '/' });
    console.log(res.payload);
};


internals.main();
```

Note how `server.listen` is never called.

## API

See the [API Reference](API.md)

---
_Source: https://npm.io/package/shot · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
