# dummee

> lightweight function stubbing for testing purposes

Latest version **1.2.0** (published 2020-06-03) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2020-06-03 |
| First published | 2019-10-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | zzyyxxww |
| Maintainers | gtarsia |

## Links

- npm: https://www.npmjs.com/package/dummee
- Repository: https://github.com/zzyyxxww/dummee
- npm.io page: https://npm.io/package/dummee

## Recent versions

- 1.2.0 (latest) — 2020-06-03
- 1.1.0 — 2020-05-12
- 1.0.0 — 2019-10-07

## README

# dummee


[![Build Status](https://travis-ci.org/zzyyxxww/dummee.svg?branch=master)](https://travis-ci.org/zzyyxxww/dummee)
[![codecov](https://codecov.io/gh/zzyyxxww/dummee/branch/master/graph/badge.svg)](https://codecov.io/gh/zzyyxxww/dummee)
[![Maintainability](https://api.codeclimate.com/v1/badges/f103756df8cb1910959c/maintainability)](https://codeclimate.com/github/zzyyxxww/dummee/maintainability)

Javascript function stubbing to test things.

* Zero deps
* Lightweight (312b unminified)
* Intuitive API

Inspired by [ninos](https://github.com/jamiebuilds/ninos).

```javascript
const dummee = require('dummee')

const stub1 = dummee()
stub1(1, 2) // => undefined
stub1.calls // => [{ args: [1, 2] }]

const stub2 = dummee((i, j) => i + j)
stub2(2, 3) // => 5

// updating the callback
stub2.cb = () => 'hey there'
stub2() // 'hey there'
```

[when to use stubbing](./docs/when-to-use-stubbing.md)

## install

`yarn add --dev dummee` or  
`npm install --save-dev dummee`

## also, this is handy:

### `dummee.stubIfTest`

This function `dummee`s a function you pass to it **only** if current `NODE_ENV` is `'test'`.

```javascript
const { stubIfTest } = require('dummee')
function myFn(...) { ... }

// if process.env.NODE_ENV is 'test'
stubIfTest(myFn) // equivalent to dummee(myFn)

// if process.env.NODE_ENV is anything else
stubIfTest(myFn) // equivalent to myFn
```

This is very useful for my controlling functions called by the function I'm currently testing.

*"That's a good trick" Anakin Skywalker*

## open to contributions

help is needed in:
* typescript definition and type check tests.

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