Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/smeijer/jest-partial

A partial matcher for Jest to simplify validation of complex structures.
https://github.com/smeijer/jest-partial

jest nodejs tests

Last synced: 16 days ago
JSON representation

A partial matcher for Jest to simplify validation of complex structures.

Awesome Lists containing this project

README

        

# jest-partial

[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)

**Partial Matcher for Jest Expect**

![animation of jest-partial matcher](./docs/jest-partial.gif)

`jest-partial` asserts that the `provided` object is a subset of the `expected`. We don't always want to verify the entire object that has been given. We often just
want to protect the properties that we need, and ignore everything else.

## Installation

With npm:

```sh
npm install --save-dev jest-partial
```

With yarn:

```sh
yarn add -D jest-partial
```

## Setup

### Jest >v24

Add `jest-partial` to your Jest `setupFilesAfterEnv` configuration. [See for help](https://jestjs.io/docs/en/configuration.html#setupfilesafterenv-array)

```json
"jest": {
"setupFilesAfterEnv": ["jest-partial"]
}
```

### Jest



Stephan Meijer

🤔 💻 🚇 🚧

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!