3.0.1 • Published 5 years ago

jsdiff-console v3.0.1

Weekly downloads
87
License
ISC
Repository
github
Last release
5 years ago

JsDiff with console output

Compares JS hashes using JsDiff and outputs the result on the console

CircleCI Coverage Status Dependency Status devDependency Status

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
3.0.1

5 years ago

3.0.0

5 years ago

2.2.1

8 years ago

2.2.0

8 years ago

2.1.0

8 years ago

2.0.0

8 years ago

1.4.2

8 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.0

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago