Giter Club home page Giter Club logo

jest-similar's Introduction

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

jest-similar's People

Contributors

anshumandas avatar dependabot[bot] avatar

Stargazers

Liu Wenyuan avatar Matthew Lee avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.