# assert-no-diff

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

Latest version **4.1.0** (published 2025-03-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install assert-no-diff
pnpm add assert-no-diff
yarn add assert-no-diff
bun add assert-no-diff
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 4.1.0 |
| Published | 2025-03-17 |
| First published | 2019-07-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kevin Goslar |
| Maintainers | kevingoslar |

## Links

- npm: https://www.npmjs.com/package/assert-no-diff
- Repository: https://github.com/kevgo/assert-no-diff
- Homepage: https://github.com/kevgo/assert-no-diff#readme
- Issues: https://github.com/kevgo/assert-no-diff/issues
- npm.io page: https://npm.io/package/assert-no-diff

## Dependencies (2)

- [diff](https://npm.io/package/diff.md) 7.0.0
- [colorette](https://npm.io/package/colorette.md) 2.0.20

## Recent versions

- 4.1.0 (latest) — 2025-03-17
- 4.0.0 — 2025-03-13
- 3.0.6 — 2021-03-02
- 3.0.5 — 2020-10-28
- 3.0.4 — 2019-11-19
- 3.0.3 — 2019-07-19
- 3.0.2 — 2019-07-15
- 3.0.1 — 2019-07-14

## README

# AssertNoDiff

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

![test status](https://github.com/kevgo/assert-no-diff/actions/workflows/tests.yml/badge.svg)
[![Code Coverage](https://coveralls.io/repos/github/kevgo/assert-no-diff/badge.svg?branch=main)](https://coveralls.io/github/kevgo/assert-no-diff?branch=main)
[![install size](https://packagephobia.now.sh/badge?p=assert-no-diff)](https://packagephobia.now.sh/result?assert-no-diff)

This library provides the JavaScript string and object diff methods of the
popular [diff](https://github.com/kpdecker/jsdiff) 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.

```javascript
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.

---
_Source: https://npm.io/package/assert-no-diff · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
