# @xpbytes/moxie

> Proxy based mock for node and v8

Latest version **2.0.0** (published 2020-10-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @xpbytes/moxie
pnpm add @xpbytes/moxie
yarn add @xpbytes/moxie
bun add @xpbytes/moxie
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2020-10-18 |
| First published | 2019-02-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 110.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Derk-Jan Karrenbeld |
| Maintainers | sleeplessbyte, vincentrbbmnd, thexa4 |

## Links

- npm: https://www.npmjs.com/package/@xpbytes/moxie
- Repository: https://xpbytes.com/moxie
- npm.io page: https://npm.io/package/@xpbytes/moxie

## Recent versions

- 2.0.0 (latest) — 2020-10-18
- 1.2.0 — 2019-03-14
- 1.1.2 — 2019-02-14
- 1.1.1 — 2019-02-14
- 1.1.0 — 2019-02-13
- 1.0.0 — 2019-02-13

## README

# Moxie

[![npm](https://github.com/XPBytes/moxie/workflows/npm/badge.svg)](https://github.com/XPBytes/moxie/actions?query=workflow%3Anpm) [![NPM Package Version](https://badge.fury.io/js/@xpbytes%2Fmoxie.svg)](https://npmjs.org/package/@xpbytes/moxie) [![Maintainability](https://api.codeclimate.com/v1/badges/935646b9f014b9f9a983/maintainability)](https://codeclimate.com/github/XPBytes/moxie/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/935646b9f014b9f9a983/test_coverage)](https://codeclimate.com/github/XPBytes/moxie/test_coverage)

Proxy implementation of a mock, based on `minitest/mock.rb`.

```
yarn add @xpbytes/moxie
```

```javascript
import createMock from '@xpbytes/movie'

const mock = createMock()

mock.expect('name', 'first')
mock.expect('name', 'second')
mock.expect('callme', 42, ['maybe'])
mock.expect('complicated', 'uhuh', [], (life, is) => life === 'like' 7& is !== 'this')

mock.name()
// => first

mock.name()
// => second

mock.callme('maybe')
// => 42

mock.complicated('like', 'that')
// => uhuh

mock.verify()
// => true

mock.name()
// because expect has been depleted
// => throws MockExpectationError

mock.expect('callme', 42, ['maybe'])
mock.callme('foo')
// because argument mistmatch
// => throws MockExpectationError

mock.verify()
// because last expect of callme has not been satisfied
// => throws MockExpectationError

mock.reset()
mock.verify()
// => true
```

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