# create-spy-obj

> Create jasmine spy objects magically

Latest version **0.0.2** (published 2019-11-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install create-spy-obj
pnpm add create-spy-obj
yarn add create-spy-obj
bun add create-spy-obj
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2019-11-11 |
| First published | 2019-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Moshe Kolodny |
| Maintainers | kolodny |

## Links

- npm: https://www.npmjs.com/package/create-spy-obj
- Repository: https://github.com/kolodny/create-spy-obj
- Homepage: https://github.com/kolodny/create-spy-obj#readme
- Issues: https://github.com/kolodny/create-spy-obj/issues
- npm.io page: https://npm.io/package/create-spy-obj

## Recent versions

- 0.0.2 (latest) — 2019-11-11
- 0.0.1 — 2019-11-06
- 0.0.0 — 2019-11-06

## README

create-spy-obj
===

Create jasmine spy objects magically

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Downloads][downloads-image]][downloads-url]

## Usage

```ts
import { createSpyObj } from 'create-spy-obj';

class MyService {
  myMethod() {
    return 'foo';
  }
}

interface MyInterface {
  getName(): string;
}

// Use it with a class
const myServiceSpyObj = createSpyObj<MyService>();
myServiceSpyObj.myMethod.and.returnValue('bar');

// Use it with an interface
const myInterfaceSpyObj = createSpyObj<MyInterface>();
myInterfaceSpyObj.getName.and.returnValue('cool');

// Use it with a class without generics (can't do the same with interfaces)
const myServiceSpyObj = createSpyObj(MyService);
myServiceSpyObj.myMethod.and.returnValue('bar');

```

### How it works

✨ Proxy magic ✨

[npm-image]: https://img.shields.io/npm/v/create-spy-obj.svg?style=flat-square
[npm-url]: https://npmjs.org/package/create-spy-obj
[travis-image]: https://img.shields.io/travis/kolodny/create-spy-obj.svg?style=flat-square
[travis-url]: https://travis-ci.org/kolodny/create-spy-obj
[downloads-image]: http://img.shields.io/npm/dm/create-spy-obj.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/create-spy-obj

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