Socket
Socket
Sign inDemoInstall

jest-diff

Package Overview
Dependencies
10
Maintainers
3
Versions
229
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jest-diff


Version published
Maintainers
3
Install size
667 kB
Created

Package description

What is jest-diff?

The jest-diff npm package is a utility primarily used to show differences between two values, typically used in testing environments to assert the equality of objects, arrays, or other data structures. It is part of the Jest testing framework but can be used independently for its diffing capabilities.

What are jest-diff's main functionalities?

Diffing two values

This feature allows you to compare two JavaScript objects and outputs a string that visually represents the differences between them. It is useful for debugging and in test assertions to see what exactly differs when a test fails.

const diff = require('jest-diff');
const a = { a: { b: { c: 5 } } };
const b = { a: { b: { c: 6 } } };
console.log(diff(a, b));

Customizing diff output

This feature allows customization of the diff output by passing options. You can specify annotations for the compared values, which helps in making the output more understandable and tailored to specific needs.

const diff = require('jest-diff');
const options = { aAnnotation: 'First', bAnnotation: 'Second' };
const a = [1, 2, 3];
const b = [2, 1, 3];
console.log(diff(a, b, options));

Other packages similar to jest-diff

Changelog

Source

jest 15.0.0

  • See https://jestjs.io/blog/2016/09/01/jest-15
  • Jest by default now also recognizes files ending in .spec.js and .test.js as test files.
  • Completely replaced most Jasmine matchers with new Jest matchers.
  • Rewrote Jest's CLI output for test failures and summaries.
  • Added --env option to override the default test environment.
  • Disabled automocking, fake timers and resetting the module registry by default.
  • Added --watchAll, made --watch interactive and added the ability to update snapshots and select test patterns in watch mode.
  • Jest uses verbose mode when running a single test file.
  • Console messages are now buffered and printed along with the test results.
  • Fix testEnvironment resolution to prefer jest-environment-{name} instead of {name} only. This prevents a module collision when using jsdom as test environment.
  • moduleNameMapper now uses a resolution algorithm.
  • Improved performance for small test runs.
  • Improved API documentation.
  • Jest now works properly with directories that have special characters in them.
  • Improvements to Jest's own test infra by merging integration and unit tests. Code coverage is now collected for Jest.
  • Added global.global to the node environment.
  • Fixed babel-jest-plugin-hoist issues with functions called mock.
  • Improved jest-react-native preset with mocks for ListView, TextInput, ActivityIndicator and ScrollView.
  • Added collectCoverageFrom to collect code coverage from untested files.
  • Rewritten code coverage support.

FAQs

Last updated on 31 Aug 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc