Socket
Socket
Sign inDemoInstall

jest-diff

Package Overview
Dependencies
10
Maintainers
4
Versions
229
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 15.1.0 to 15.2.0-alpha.c681f819

9

build/constants.js

@@ -15,3 +15,8 @@ /**

module.exports.NO_DIFF_MESSAGE =
chalk.dim.underline('Compared values have no visual difference');
exports.NO_DIFF_MESSAGE =
chalk.dim('Compared values have no visual difference.');
exports.SIMILAR_MESSAGE =
chalk.dim(
'Compared values serialize to the same structure.\n' +
'Printing internal object structure without calling `toJSON` instead.');

@@ -43,3 +43,3 @@ /**

chalk.red :
part.removed ? chalk.green : chalk.white;
part.removed ? chalk.green : chalk.dim;

@@ -46,0 +46,0 @@ if (lines[lines.length - 1] === '') {

@@ -21,7 +21,18 @@ /**

require('jest-matcher-utils');const getType = _require.getType;
const prettyFormat = require('pretty-format');
const prettyFormat = require('pretty-format');var _require2 =
const jsxLikePlugins = [ReactTestComponentPlugin, ReactElementPlugin];
const NO_DIFF_MESSAGE = require('./constants').NO_DIFF_MESSAGE;
require('./constants');const NO_DIFF_MESSAGE = _require2.NO_DIFF_MESSAGE;const SIMILAR_MESSAGE = _require2.SIMILAR_MESSAGE;
const PLUGINS = [ReactTestComponentPlugin, ReactElementPlugin];
const FORMAT_OPTIONS = {
plugins: PLUGINS };
const FALLBACK_FORMAT_OPTIONS = {
callToJSON: false,
plugins: PLUGINS };
// Generate a string that will highlight the difference between two values

@@ -53,9 +64,31 @@ // with green and red. (similar to how github does code diffing)

default:
return diffStrings(
prettyFormat(a, { plugins: jsxLikePlugins }, options),
prettyFormat(b, { plugins: jsxLikePlugins }, 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": "15.1.0",
"version": "15.2.0-alpha.c681f819",
"repository": {

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

"diff": "^3.0.0",
"jest-matcher-utils": "^15.1.0",
"pretty-format": "^3.7.0"
"jest-matcher-utils": "^15.2.0-alpha.c681f819",
"pretty-format": "~4.2.1"
},

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

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