Socket
Socket
Sign inDemoInstall

jest-diff

Package Overview
Dependencies
Maintainers
4
Versions
230
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-diff - npm Package Compare versions

Comparing version 17.0.3 to 18.0.0

65

build/index.js

@@ -15,4 +15,4 @@ /**

const ReactElementPlugin = require('pretty-format/plugins/ReactElement');
const ReactTestComponentPlugin = require('pretty-format/plugins/ReactTestComponent');
const ReactElementPlugin = require('pretty-format/build/plugins/ReactElement');
const ReactTestComponentPlugin = require('pretty-format/build/plugins/ReactTestComponent');

@@ -64,32 +64,49 @@ const chalk = require('chalk');

return null;
case 'map':
return compareObjects(sortMap(a), sortMap(b), options);
case 'set':
return compareObjects(sortSet(a), sortSet(b), options);
default:
let diffMessage;
let hasThrown = false;
return compareObjects(a, b, options);}
try {
diffMessage = diffStrings(
prettyFormat(a, FORMAT_OPTIONS),
prettyFormat(b, FORMAT_OPTIONS),
options);
}
} catch (e) {
hasThrown = true;
}
function sortMap(map) {
return new Map(Array.from(map.entries()).sort());
}
// If the comparison yields no results, compare again but this time
// without calling `toJSON`. It's also possible that toJSON might throw.
if (!diffMessage || diffMessage === NO_DIFF_MESSAGE) {
diffMessage = diffStrings(
prettyFormat(a, FALLBACK_FORMAT_OPTIONS),
prettyFormat(b, FALLBACK_FORMAT_OPTIONS),
options);
function sortSet(set) {
return new Set(Array.from(set.values()).sort());
}
if (diffMessage !== NO_DIFF_MESSAGE && !hasThrown) {
diffMessage = SIMILAR_MESSAGE + '\n\n' + diffMessage;
}
}
return diffMessage;}
function compareObjects(a, b, options) {
let diffMessage;
let hasThrown = false;
try {
diffMessage = diffStrings(
prettyFormat(a, FORMAT_OPTIONS),
prettyFormat(b, FORMAT_OPTIONS),
options);
} catch (e) {
hasThrown = true;
}
// If the comparison yields no results, compare again but this time
// without calling `toJSON`. It's also possible that toJSON might throw.
if (!diffMessage || diffMessage === NO_DIFF_MESSAGE) {
diffMessage = diffStrings(
prettyFormat(a, FALLBACK_FORMAT_OPTIONS),
prettyFormat(b, FALLBACK_FORMAT_OPTIONS),
options);
if (diffMessage !== NO_DIFF_MESSAGE && !hasThrown) {
diffMessage = SIMILAR_MESSAGE + '\n\n' + diffMessage;
}
}
return diffMessage;
}
module.exports = diff;
{
"name": "jest-diff",
"version": "17.0.3",
"version": "18.0.0",
"repository": {

@@ -13,4 +13,4 @@ "type": "git",

"diff": "^3.0.0",
"jest-matcher-utils": "^17.0.3",
"pretty-format": "~4.2.1"
"jest-matcher-utils": "^18.0.0",
"pretty-format": "^18.0.0"
},

@@ -17,0 +17,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc