{"id":13525866,"url":"https://github.com/developit/preact-jsx-chai","last_synced_at":"2025-10-31T08:39:16.782Z","repository":{"id":49434968,"uuid":"48400736","full_name":"developit/preact-jsx-chai","owner":"developit","description":":white_check_mark: Add JSX assertions to Chai, with support for Preact Components.","archived":false,"fork":false,"pushed_at":"2020-05-29T20:15:31.000Z","size":125,"stargazers_count":56,"open_issues_count":7,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T11:16:10.293Z","etag":null,"topics":["chai","chai-plugin","jsx-assertions","jsx-chai","preact","test","testing"],"latest_commit_sha":null,"homepage":"http://npm.im/preact-jsx-chai","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/developit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-22T00:05:32.000Z","updated_at":"2024-03-13T12:01:11.000Z","dependencies_parsed_at":"2022-09-06T19:20:12.972Z","dependency_job_id":null,"html_url":"https://github.com/developit/preact-jsx-chai","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-jsx-chai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-jsx-chai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-jsx-chai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-jsx-chai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/developit","download_url":"https://codeload.github.com/developit/preact-jsx-chai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501234,"owners_count":21114635,"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":["chai","chai-plugin","jsx-assertions","jsx-chai","preact","test","testing"],"created_at":"2024-08-01T06:01:22.952Z","updated_at":"2025-10-31T08:39:16.732Z","avatar_url":"https://github.com/developit.png","language":"JavaScript","readme":"# preact-jsx-chai\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/developit/preact-jsx-chai.svg)](https://greenkeeper.io/)\n\n[![NPM](http://img.shields.io/npm/v/preact-jsx-chai.svg)](https://www.npmjs.com/package/preact-jsx-chai)\n[![travis-ci](https://travis-ci.org/developit/preact-jsx-chai.svg)](https://travis-ci.org/developit/preact-jsx-chai)\n\nExtend Chai with support for asserting JSX equality \u0026 contents with support for [Preact] Components.\n\n(Heavily) inspired by [jsx-chai].\n\n\n---\n\n\n### Usage\n\n```js\nimport { h } from 'preact'; /** @jsx h */\n\nimport chai, { expect } from 'chai';\nimport assertJsx from 'preact-jsx-chai';\nchai.use(assertJsx);\n\n// check if two JSX DOMs are deeply equal:\nexpect(\n\t\u003cdiv id=\"1\"\u003ea\u003c/div\u003e\n).to.deep.equal(\n\t\u003cdiv id=\"1\"\u003ea\u003c/div\u003e\n);\n\n// check if a given JSX DOM contains the given fragment:\nexpect(\n\t\u003cdiv\u003e \u003cspan\u003efoo!\u003c/span\u003e \u003c/div\u003e\n).to.contain(\n\t\u003cspan\u003efoo!\u003c/span\u003e\n);\n```\n\n\u003e **Note:** in environments like Karma where chai is available as a global, `preact-jsx-chai` will automatically register itself on import. Don't worry, though, this plugin is smart enough to avoid registering itself multiple times.\n\n\n---\n\n\n### Options\n\nThere are a few global options available to customize how `preact-jsx-chai` asserts over VNodes.\n\n\n| Name            | Type     | Default | Description\n|-----------------|----------|---------|-------------\n| `isJsx`         | Function | _auto_  | Override the detection of values as being JSX VNodes.\n| `functions`     | Boolean  | _true_  | If `false`, props with function values will be omitted from the comparison entirely\n| `functionNames` | Boolean  | _true_  | If `false`, ignores function names and bound state, asserting only that the compared props are functions\n\n\n##### To set these options:\n\n```js\nimport { options } from 'preact-jsx-chai';\noptions.functions = false;\n\n// or:\n\nimport jsxChai from 'preact-jsx-chai';\njsxChai.options.functions = false;\n```\n\n\n---\n\n### Assertions\n\nDeep, fully rendered equality/inclusion is checked for: `.deep.equal`, `.eql`, `.include`, and `.contain`\n\nShallow, JSX only equality/inclusion is checked for: `.equal`, `.shallow.include`, and `.shallow.contain`\n\n```js\nlet Outer = ({a}) =\u003e \u003cInner a={a}/\u003e\nlet Inner = ({a}) =\u003e \u003cdiv\u003e{a}\u003c/div\u003e\n\n// JSX tests\nexpect(\u003cOuter /\u003e).to.be.jsx\nexpect('Outer').to.not.be.jsx\n\n// Deep equality tests\nexpect(\u003cOuter a=\"foo\"/\u003e).to.deep.equal(\u003cInner a=\"foo\" notRenderedProp=\"x\" /\u003e)\nexpect(\u003cOuter a=\"foo\"/\u003e).to.deep.equal(\u003cdiv\u003efoo\u003c/div\u003e/\u003e)\nexpect(\u003cOuter a=\"foo\"/\u003e).to.not.deep.equal(\u003cInner a=\"NotBar\"/\u003e)\nexpect(\u003cOuter /\u003e).to.eql(\u003cOuter /\u003e) // .eql is shorthand for .deep.equal\nexpect(\u003cOuter a=\"foo\"/\u003e).to.not.eql(\u003cInner a=\"NotFoo\"/\u003e)\n\n// Shallow Equality tests\nexpect(\u003cOuter a=\"foo\"/\u003e).to.equal(\u003cInner a=\"foo\" /\u003e)\nexpect(\u003cOuter a=\"foo\"/\u003e).to.not.equal(\u003cInner a=\"foo\" verifiedJSXProp=\"x\" /\u003e)\nexpect(\u003cOuter a=\"foo\"/\u003e).to.not.equal(\u003cdiv\u003efoo\u003c/div\u003e) // \u003cInner /\u003e is not rendered\n\nlet WrappedOuter = ({a}) =\u003e \u003cdiv id=\"outer\"\u003e\u003cInner a={a} /\u003e\u003c/div\u003e\n\n// Deep includes/contains tests\nexpect(\u003cWrappedOuter a=\"foo\" /\u003e).to.include(\u003cdiv\u003efoo\u003c/div\u003e)\nexpect(\u003cWrappedOuter a=\"foo\" /\u003e).to.contain(\u003cdiv\u003efoo\u003c/div\u003e)\nexpect(\u003cWrappedOuter a=\"foo\" /\u003e).to.contain(\u003cInner a=\"foo\" /\u003e)\nexpect(\u003cWrappedOuter a=\"foo\" /\u003e).to.not.include(\u003cdiv\u003eBad Div\u003c/div\u003e)\n\n// Shallow includes/contains tests\nexpect(\u003cWrappedOuter a=\"foo\" /\u003e).to.shallow.contain(\u003cInner a=\"foo\" /\u003e)\nexpect(\u003cWrappedOuter a=\"foo\" /\u003e).to.not.shallow.include(\u003cdiv\u003efoo\u003c/div\u003e)\n```\n\n---\n\n\n### License\n\n[MIT]\n\n\n[Preact]: https://github.com/developit/preact\n[jsx-chai]: https://github.com/bkonkle/jsx-chai\n[MIT]: http://choosealicense.com/licenses/mit/\n","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Fpreact-jsx-chai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevelopit%2Fpreact-jsx-chai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Fpreact-jsx-chai/lists"}