https://github.com/mvasilkov/assert-equal-html
Assert the equality of two HTML fragments
https://github.com/mvasilkov/assert-equal-html
assert equality html typescript
Last synced: 8 months ago
JSON representation
Assert the equality of two HTML fragments
- Host: GitHub
- URL: https://github.com/mvasilkov/assert-equal-html
- Owner: mvasilkov
- License: mit
- Created: 2020-04-28T08:34:01.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-18T18:09:44.000Z (over 5 years ago)
- Last Synced: 2025-04-16T00:15:56.857Z (8 months ago)
- Topics: assert, equality, html, typescript
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/assert-equal-html
- Size: 18.6 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
assert-equal-html
===
Assert the equality of two HTML fragments
[![npm][npm-badge]][npm-url]
[![dependencies][dependencies-badge]][dependencies-url]
---
Installation
---
```sh
npm add assert-equal-html
```
Usage
---
```javascript
const { assertEqual } = require('assert-equal-html')
assertEqual(
'Link',
'Link')
```
The comparison rules are as follows:
- The DOCTYPE, if present, is ignored
- HTML comments are also ignored
- Attributes and class names are sorted
- ASCII whitespace is stripped and collapsed
> [ASCII whitespace][1] is U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020 SPACE.
>
> To [strip and collapse ASCII whitespace][2] in a string, replace any sequence of one or more
> consecutive code points that are ASCII whitespace in the string with a single U+0020 SPACE
> code point, and then remove any leading and trailing ASCII whitespace from that string.
[1]: https://infra.spec.whatwg.org/#ascii-whitespace
[2]: https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
Syntax
---
**`assertEqual(actual, expected[, message])`**
Tests HTML equality between the `actual` and `expected` parameters.
**`assertNotEqual(actual, expected[, message])`**
Tests HTML inequality between the `actual` and `expected` parameters.
License
---
MIT
[npm-badge]: https://img.shields.io/npm/v/assert-equal-html.svg?style=flat
[npm-url]: https://www.npmjs.com/package/assert-equal-html
[dependencies-badge]: https://img.shields.io/librariesio/release/npm/assert-equal-html?style=flat
[dependencies-url]: https://www.npmjs.com/package/assert-equal-html?activeTab=dependencies