# @zthun/works.jest

> A testing library that helps with common testing patterns in jest.

Latest version **4.0.0** (published 2022-05-26) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @zthun/works.jest
pnpm add @zthun/works.jest
yarn add @zthun/works.jest
bun add @zthun/works.jest
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2022-05-26 |
| First published | 2020-07-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 227.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Anthony Bonta |
| Maintainers | zthun |

## Links

- npm: https://www.npmjs.com/package/@zthun/works.jest
- Repository: https://github.com/zthun/works
- Homepage: https://github.com/zthun/works#readme
- Issues: https://github.com/zthun/works/issues
- npm.io page: https://npm.io/package/@zthun/works.jest

## Recent versions

- 4.0.0 (latest) — 2022-05-26
- 3.0.2 — 2022-01-14
- 3.0.0 — 2021-12-22
- 2.1.0 — 2021-12-19
- 2.0.0 — 2021-11-15
- 1.0.0 — 2021-08-09
- 1.0.0-29 — 2021-08-09
- 1.0.0-26 — 2021-05-27
- 1.0.0-25 — 2021-03-27
- 1.0.0-24 — 2021-03-15
- 1.0.0-22 — 2021-02-14
- 1.0.0-17 — 2020-10-29
- 1.0.0-15 — 2020-10-10
- 1.0.0-7 — 2020-07-16
- 1.0.0-6 — 2020-07-16

## README

# Description

This package extends upon jest to add additional methods for mocking. It also adds some common assertions found throughout @zthun scoped projects.

## Installation

```sh
# NPM
npm install @zthun/works.jest
# Yarn
yarn add @zthun/works.jest
```

## Usage

The most useful feature in this package is going to be the createMocked method which should feel familiar to those who used jasmine for a long time to do unit tests. It's the equivalent of the jasmine.createSpyObj(...) method.

```ts
import { createMocked } from '@zthun/works.jest';

describe('My object with services.', () => {
  let service: jest.Mocked<IMyService>;

  beforeEach(() => {
    service = createMocked<IMyService>(['get', 'put']);

    service.get.mockReturnValue('You got it.');
  });

  it('should mock the service.', () => {
    // Arrange
    const target = service;
    // Act
    const actual = service.get();
    // Assert
    expect(actual).toEqual('You got it.');
  });
});
```

Most other methods deal with common assertions made throughout @zthun scoped projects, especially those which test builder objects and getter/setter properties. See the documentation for each individual method to see if any would apply to your specific requirements.

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