Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Asserts the equality of JavaScript strings and objects with human-friendly, Bash-colored diffs as error messages.

License

Notifications You must be signed in to change notification settings

kevgo/assert-no-diff

Repository files navigation

AssertNoDiff

Asserts the equality of JavaScript strings and objects with human-friendly, Bash-colored diffs as error messages.

test status Code Coverage install size

This library provides the JavaScript string and object diff methods of the popular diff library as assertions. The exceptions thrown by the assertions highlight the differences of the actual and expected values with human-friendly Bash-colored messages. This is useful for verifying the equality of larger strings or data structures in tests.

import * as assertNoDiff from "assert-no-diff"

// Diffs two JSON objects, comparing the fields defined on each.
// The order of fields does not matter.
assertNoDiff.json(actualJson, expectedJson)

// Asserts that two blocks of text are equal, comparing character by character.
assertNoDiff.chars(actualString, expectedString)

// Diffs two blocks of text, comparing word by word.
// Whitespace is significant.
assertNoDiff.wordsWithSpace(actualString, expectedString)

// Diffs two blocks of text, comparing line by line.
// Ignores leading and trailing whitespace.
assertNoDiff.trimmedLines(actualString, expectedString)

You can provide a custom error message as an optional third parameter.

About

Asserts the equality of JavaScript strings and objects with human-friendly, Bash-colored diffs as error messages.

Resources

License

Stars

Watchers

Forks

Packages

No packages published