jest-diff
Advanced tools
Comparing version 19.0.0 to 19.1.0-alpha.eed82034
@@ -15,8 +15,8 @@ /** | ||
exports.NO_DIFF_MESSAGE = | ||
chalk.dim('Compared values have no visual difference.'); | ||
exports.NO_DIFF_MESSAGE = chalk.dim( | ||
'Compared values have no visual difference.'); | ||
exports.SIMILAR_MESSAGE = | ||
chalk.dim( | ||
exports.SIMILAR_MESSAGE = chalk.dim( | ||
'Compared values serialize to the same structure.\n' + | ||
'Printing internal object structure without calling `toJSON` instead.'); |
@@ -36,10 +36,6 @@ /** | ||
const getColor = (added, removed) => | ||
added ? | ||
chalk.red : | ||
removed ? chalk.green : chalk.dim; | ||
added ? chalk.red : removed ? chalk.green : chalk.dim; | ||
const getBgColor = (added, removed) => | ||
added ? | ||
chalk.bgRed : | ||
removed ? chalk.bgGreen : chalk.dim; | ||
added ? chalk.bgRed : removed ? chalk.bgGreen : chalk.dim; | ||
@@ -50,4 +46,6 @@ const highlightTrailingWhitespace = (line, bgColor) => | ||
const getAnnotation = options => | ||
chalk.green('- ' + (options && options.aAnnotation || 'Expected')) + '\n' + | ||
chalk.red('+ ' + (options && options.bAnnotation || 'Received')) + '\n\n'; | ||
chalk.green('- ' + (options && options.aAnnotation || 'Expected')) + | ||
'\n' + | ||
chalk.red('+ ' + (options && options.bAnnotation || 'Received')) + | ||
'\n\n'; | ||
@@ -57,3 +55,5 @@ const diffLines = (a, b) => { | ||
return { | ||
diff: diff.diffLines(a, b).map(part => {const | ||
diff: diff. | ||
diffLines(a, b). | ||
map(part => {const | ||
added = part.added,removed = part.removed; | ||
@@ -72,8 +72,12 @@ if (part.added || part.removed) { | ||
return lines.map(line => { | ||
return lines. | ||
map(line => { | ||
const highlightedLine = highlightTrailingWhitespace(line, bgColor); | ||
const mark = color(part.added ? '+' : part.removed ? '-' : ' '); | ||
return mark + ' ' + color(highlightedLine) + '\n'; | ||
}).join(''); | ||
}).join('').trim(), | ||
}). | ||
join(''); | ||
}). | ||
join(''). | ||
trim(), | ||
isDifferent }; | ||
@@ -88,4 +92,4 @@ | ||
// we can be sure that at least 1 line has been "hidden". | ||
const shouldShowPatchMarks = | ||
(hunk, oldLinesCount) => oldLinesCount > hunk.oldLines; | ||
const shouldShowPatchMarks = (hunk, oldLinesCount) => | ||
oldLinesCount > hunk.oldLines; | ||
@@ -112,5 +116,7 @@ const createPatchMark = hunk => { | ||
return { | ||
diff: diff.structuredPatch('', '', a, b, '', '', options). | ||
diff: diff. | ||
structuredPatch('', '', a, b, '', '', options). | ||
hunks.map(hunk => { | ||
const lines = hunk.lines.map(line => { | ||
const lines = hunk.lines. | ||
map(line => { | ||
const added = line[0] === '+'; | ||
@@ -124,3 +130,4 @@ const removed = line[0] === '-'; | ||
return color(highlightedLine) + '\n'; | ||
}).join(''); | ||
}). | ||
join(''); | ||
@@ -131,3 +138,5 @@ isDifferent = true; | ||
lines; | ||
}).join('').trim(), | ||
}). | ||
join(''). | ||
trim(), | ||
isDifferent }; | ||
@@ -134,0 +143,0 @@ |
@@ -18,2 +18,3 @@ /** | ||
const AsymmetricMatcherPlugin = require('pretty-format/build/plugins/AsymmetricMatcher'); | ||
const ImmutablePlugins = require('pretty-format/build/plugins/ImmutablePlugins'); | ||
@@ -33,4 +34,4 @@ const chalk = require('chalk'); | ||
ReactElementPlugin, | ||
AsymmetricMatcherPlugin]; | ||
AsymmetricMatcherPlugin]. | ||
concat(ImmutablePlugins); | ||
const FORMAT_OPTIONS = { | ||
@@ -71,7 +72,5 @@ plugins: PLUGINS }; | ||
if (expectedType !== getType(b)) { | ||
return ( | ||
' Comparing two different types of values.' + | ||
` Expected ${chalk.green(expectedType)} but ` + | ||
`received ${chalk.red(getType(b))}.`); | ||
return ' Comparing two different types of values.' + | ||
` Expected ${chalk.green(expectedType)} but ` + | ||
`received ${chalk.red(getType(b))}.`; | ||
} | ||
@@ -78,0 +77,0 @@ |
{ | ||
"name": "jest-diff", | ||
"version": "19.0.0", | ||
"version": "19.1.0-alpha.eed82034", | ||
"repository": { | ||
@@ -12,6 +12,6 @@ "type": "git", | ||
"chalk": "^1.1.3", | ||
"diff": "^3.0.0", | ||
"jest-matcher-utils": "^19.0.0", | ||
"pretty-format": "^19.0.0" | ||
"diff": "^3.2.0", | ||
"jest-matcher-utils": "^19.1.0-alpha.eed82034", | ||
"pretty-format": "^19.1.0-alpha.eed82034" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10349
6
236
1
80
2
+ Addedjest-matcher-utils@19.1.0-alpha.eed82034(transitive)
+ Addedpretty-format@19.1.0-alpha.eed82034(transitive)
- Removedjest-matcher-utils@19.0.0(transitive)
- Removedpretty-format@19.0.0(transitive)
Updateddiff@^3.2.0