1.0.8 • Published 4 years ago

jest-similar v1.0.8

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Problem

Jest is an amazing test runner and has some awesome assertion APIs built in by default. However I was not able to find a simple solution for testing deep equality while ignoring order. Even (jest-extended)https://github.com/jest-community/jest-extended did not have an easy solution.

Solution

This simple jest extension to test deep equality while ignoring order of object properties and array elements This now also checks contained string similarity by ignoring case, spaces and line breaks.

Installation

With npm:

npm install --save-dev jest-similar

With yarn:

yarn add -D jest-similar

Setup

Jest >v24

Add jest-similar to your Jest setupFilesAfterEnv configuration. See for help

"jest": {
  "setupFilesAfterEnv": ["jest-similar"]
}

Jest <v23

"jest": {
  "setupTestFrameworkScriptFile": "jest-similar"
}

If you are already using another test framework, like jest-chain, then you should create a test setup file and require each of the frameworks you are using.

For example:

// ./testSetup.js
require('jest-similar');

Then in your Jest config:

"jest": {
  "setupTestFrameworkScriptFile": "./testSetup.js"
}

Typescript

If your editor does not recognise the custom jest-similar matchers, add a global.d.ts file to your project with:

import 'jest-similar';

API

.toBeSimilar()

For usage see test.js

LICENSE

MIT

Todos

  • given string from files figure out common areas jumbled up
1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago