{"id":15413437,"url":"https://github.com/i-like-robots/chai-html","last_synced_at":"2025-07-16T05:04:22.496Z","repository":{"id":52794814,"uuid":"45536618","full_name":"i-like-robots/chai-html","owner":"i-like-robots","description":"☕️ A focussed HTML assertions plugin for Chai.","archived":false,"fork":false,"pushed_at":"2025-02-12T21:36:51.000Z","size":201,"stargazers_count":7,"open_issues_count":1,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-29T17:49:50.763Z","etag":null,"topics":["assertions","chai","chai-html","javascript","nodejs"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/chai-html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/i-like-robots.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-04T12:10:22.000Z","updated_at":"2025-02-12T21:36:55.000Z","dependencies_parsed_at":"2022-08-23T03:01:08.846Z","dependency_job_id":"2f3327e6-4927-4990-896b-44a204a2977e","html_url":"https://github.com/i-like-robots/chai-html","commit_stats":{"total_commits":116,"total_committers":7,"mean_commits":"16.571428571428573","dds":"0.43103448275862066","last_synced_commit":"47c0ac7294a7611e8452a19c45b4831c4f75243e"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/i-like-robots/chai-html","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-like-robots%2Fchai-html","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-like-robots%2Fchai-html/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-like-robots%2Fchai-html/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-like-robots%2Fchai-html/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/i-like-robots","download_url":"https://codeload.github.com/i-like-robots/chai-html/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-like-robots%2Fchai-html/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265483213,"owners_count":23774167,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assertions","chai","chai-html","javascript","nodejs"],"created_at":"2024-10-01T16:57:04.691Z","updated_at":"2025-07-16T05:04:22.416Z","avatar_url":"https://github.com/i-like-robots.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chai-html\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/i-like-robots/chai-html/blob/main/LICENSE) ![build status](https://github.com/i-like-robots/chai-html/actions/workflows/test.yml/badge.svg?branch=main) [![npm version](https://img.shields.io/npm/v/chai-html.svg?style=flat)](https://www.npmjs.com/package/chai-html)\n\nA focussed HTML assertions plugin for [Chai](http://chaijs.com/).\n\n## Installation\n\nThis is a [Node.js] module available through the [npm] registry. Node.js 18 or higher is required.\n\n```sh\n$ npm install --save-dev chai-html\n```\n\n👋 _Please note_ this package is for Chai v5 and is [ESM](https://nodejs.org/api/esm.html) only. For Chai v4 and CommonJS support use [version 2][v2] of this package.\n\n[Node.js]: https://nodejs.org/en/\n[npm]: https://www.npmjs.com/\n[v2]: https://github.com/i-like-robots/chai-html/tree/v2\n\n## Usage\n\n```js\nimport { use, expect } from 'chai'\nimport chaiHtml from 'chai-html'\n\n// Register the plugin\nuse(chaiHtml)\n\n// Write assertions!\nexpect('\u003cdiv\u003e\u003cimg /\u003e\u003c/div\u003e').html.to.equal('\u003cdiv\u003e\u003cimg\u003e\u003c/div\u003e')\nexpect('\u003ch1\u003eHello World!\u003c/h1\u003e').html.to.not.equal('\u003ch1\u003eHallo Welt!\u003c/h1\u003e')\n```\n\nHTML assertions will throw an error directing you to the change, so instead of squinting at a long HTML string you'll get something useful:\n\n```js\nexpect('\u003cimg /\u003e').html.to.equal('\u003cbr /\u003e')\n// throws: tag \u003cimg\u003e was changed to tag \u003cbr\u003e\n\nexpect('\u003cimg src=\"...\" /\u003e').html.to.equal('\u003cimg src=\"...\" alt=\"...\" /\u003e')\n// throws: attribute [alt=\"...\"] has been added\n\nexpect('\u003cp\u003eHello World!\u003c/p\u003e Hej!').html.to.equal('\u003cp\u003eHello World!\u003c/p\u003e')\n// throws: text \" Hej!\" has been removed\n```\n\n### .ignoringComments\n\nAdd the `ignoringComments` flag to the chain to ignore HTML comments.\n\n```js\nexpect('\u003cdiv\u003e\u003c!--Comment--\u003e\u003c/div\u003e').html.ignoringComments.to.equal('\u003cdiv\u003e\u003c/div\u003e')\n```\n\n## How does it work?\n\nUnderneath this plugin uses [parse5](https://github.com/inikulin/parse5) to parse the given HTML strings and normalize the generated trees before being compared. This means that although the two strings of markup may not be the same they should generate equivalent structures.\n\n## Credits\n\nThis plugin is inspired by the similar [chai-xml](https://www.npmjs.com/package/chai-xml) plugin.\n\n## License\n\nThis package is MIT licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi-like-robots%2Fchai-html","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fi-like-robots%2Fchai-html","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi-like-robots%2Fchai-html/lists"}