# sneer

> Type-safe mocking utilities

Latest version **1.0.1** (published 2019-03-14) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-03-14 |
| First published | 2018-03-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Vladimir Sabev |
| Maintainers | vdsabev |
| Keywords | typescript, jest, jasmine, test, mock, mocking |

## Links

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

## 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
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-03-14
- 1.0.0-rc.2 (next) — 2019-03-14
- 0.2.0 — 2018-04-27
- 0.1.2 — 2018-03-20
- 0.1.1 — 2018-03-20
- 0.1.0 — 2018-03-20

## README

[![downloads][downloads-badge]][npmcharts]
[![version][version-badge]][package]
[![MIT License][license-badge]][license]

<h1 align="center">
  Sneer 😏
</h1>
<p align="center">Type-safe mocking utilities</p>

## Why?
You want to write test mocks in TypeScript while preserving type safety and getting meaningful type errors.

## Installation
```
npm install sneer -D
```

## Usage
```ts
import {
  mockPartial,
  mockPartialArray,
  mockRecursivePartial,
  mockRecursivePartialArray,
} from 'sneer';
```

### `mockPartial`
### `mockPartialArray`
Casts an object (or array of objects) to a type `T` while only requiring a partial implementation of the type to be passed. This allows us to easily mock an object while writing tests without having to define all of the properties of an object.

Example:
```ts
const store = mockPartial<Store<State>>({
  select: jest.fn((selector: (state: State) => any) => Observable.of(selector(state))),
});
```

### `mockRecursivePartial`
### `mockRecursivePartialArray`
Same as `mockPartial` and `mockPartialArray`, but recursively partial 🙃

Example:
```ts
const svg = mockRecursivePartial<SVGSVGElement>({
  x: {
    baseVal: { value: 1 }
  }
});
```

[version-badge]: https://img.shields.io/npm/v/sneer.svg?style=flat-square
[package]: https://www.npmjs.com/package/sneer
[downloads-badge]: https://img.shields.io/npm/dm/sneer.svg?style=flat-square
[npmcharts]: https://npmcharts.com/compare/sneer
[license-badge]: https://img.shields.io/npm/l/sneer.svg?style=flat-square
[license]: https://github.com/vdsabev/sneer/blob/master/LICENSE.md

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