jest-diff
Advanced tools
Comparing version 15.1.0 to 15.2.0-alpha.c681f819
@@ -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": { |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5353
130
2
+ Addedjest-matcher-utils@15.2.0-alpha.c681f819(transitive)
+ Addedpretty-format@4.2.3(transitive)
- Removedjest-matcher-utils@15.1.0(transitive)
- Removedpretty-format@3.8.0(transitive)
Updatedpretty-format@~4.2.1