# should-spies

> Small spies for should.js

Latest version **1.1.0** (published 2017-02-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install should-spies
pnpm add should-spies
yarn add should-spies
bun add should-spies
```

## 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.1.0 |
| Published | 2017-02-15 |
| First published | 2016-08-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Denis Bardadym |
| Maintainers | btd |
| Keywords | should, spy, spies |

## Links

- npm: https://www.npmjs.com/package/should-spies
- Repository: https://github.com/shouldjs/spies
- Homepage: https://github.com/shouldjs/spies#readme
- Issues: https://github.com/shouldjs/spies/issues
- npm.io page: https://npm.io/package/should-spies

## Alternatives

- [pagerjs](https://npm.io/package/pagerjs.md) — 60 weekly downloads
- [whistle.savefor-mock](https://npm.io/package/whistle.savefor-mock.md) — 4 weekly downloads
- [@xesam/cloud-core](https://npm.io/package/@xesam/cloud-core.md) — 0 weekly downloads
- [@xesam/cloud-vendor-spyun](https://npm.io/package/@xesam/cloud-vendor-spyun.md) — 0 weekly downloads
- [@visiblevc/ember-api-mocks](https://npm.io/package/@visiblevc/ember-api-mocks.md) — 0 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2017-02-15
- 1.0.0 — 2016-08-14

## README

# spies
Small pretty basic spies for should.js

# Installation

Just call this module after should.js

# Usage

```js
var spy = should.spy();

spy.should.not.be.called();

spy(1, 2, 3);

spy.should.be.calledWith(1, 2, 3);

var obj = {};

spy.call(obj);

spy.should.be.calledOn(obj);
```

# API

`should.spy([funcion])` - creates spy that optionally call passed function

`should.spy.on(obj, methodName)` - creates spy replaces methodName of obj

`should.spy.returns(value)` - creates spy that always return value

`should.spy.throws(err)`, `should.spy.throws(ErrorConstructor, [message])`, `should.spy.throws([message])` - create spy that always throw error

# Assertions

```js
var spy = should.spy();

// called checks if spy was called
spy.should.not.be.called();

spy();

spy.should.be.called();

spy(1, 2, 3);

// checks if spy was called with given arguments
spy.should.be.calledWith(1, 2, 3);

var obj = {}
spy.call(obj);
spy.should.be.calledOn(obj);


var spy1 = should.spy();
var spy2 = should.spy();

spy1();
spy2();

spy2.should.be.calledAfter(spy1);
spy1.should.be.calledBefore(spy2);
```

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