3.0.1 • Published 5 years ago
jsdiff-console v3.0.1
JsDiff with console output
Compares JS hashes using JsDiff and outputs the result on the console
This is a very simple helper method for printing the differences between two JSON or string variables to the console, for example in unit tests. It wraps the excellent diff module.
jsdiff = require("jsdiff-console")
// compare objects
jsdiff.json(actualJson, expectedJson)
// compare strings and highlight the differences character-by-character
jsdiff.chars(actualString, expectedString)
// compare strings and highlight the mismatching words, whitespace-sensitive
jsdiff.wordsWithSpace(actualString, expectedString)
// compare strings and highlight the mismatching lines, ignoring whitespace around them
jsdiff.trimmedLines(actualString, expectedString)
If the two given values are different, the jsdiff
methods throw an error with
a console-formatted message. This will cause your test runtime to fail the
current unit test and print a nicely readable diff of your objects.
You can provide a custom error message as an optional third parameter.
Development
- run all tests:
make test
- update dependencies:
make update
- see all available make commands:
make help
- deploy a new version:
- commit an update with new version in
package.json
on master - run
npm publish
- commit an update with new version in