{"id":15685853,"url":"https://github.com/smacker/jasmine-expect-jsx","last_synced_at":"2025-10-20T11:53:18.690Z","repository":{"id":57279366,"uuid":"47600500","full_name":"smacker/jasmine-expect-jsx","owner":"smacker","description":"Adds `toEqualJSX` method to jasmine and jest assertions","archived":false,"fork":false,"pushed_at":"2020-05-13T04:11:18.000Z","size":3058,"stargazers_count":9,"open_issues_count":4,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T17:52:02.765Z","etag":null,"topics":["jasmine","jest","jsx","react"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smacker.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-08T05:25:29.000Z","updated_at":"2019-07-17T10:29:11.000Z","dependencies_parsed_at":"2022-09-18T12:41:27.528Z","dependency_job_id":null,"html_url":"https://github.com/smacker/jasmine-expect-jsx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fjasmine-expect-jsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fjasmine-expect-jsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fjasmine-expect-jsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fjasmine-expect-jsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smacker","download_url":"https://codeload.github.com/smacker/jasmine-expect-jsx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252931391,"owners_count":21827104,"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":["jasmine","jest","jsx","react"],"created_at":"2024-10-03T17:32:01.078Z","updated_at":"2025-10-20T11:53:13.639Z","avatar_url":"https://github.com/smacker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jasmine-expect-jsx [![npm](https://img.shields.io/npm/v/jasmine-expect-jsx.svg?maxAge=2592000)](https://www.npmjs.com/package/jasmine-expect-jsx) [![Build Status](https://api.travis-ci.org/smacker/jasmine-expect-jsx.svg)](https://travis-ci.org/smacker/jasmine-expect-jsx)\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/smacker/jasmine-expect-jsx.svg)](https://greenkeeper.io/)\n\nAdds `toEqualJSX` and `toIncludeJSX` methods to jasmine assertions.\nUses Algolia's [react-element-to-jsx-string](https://github.com/algolia/react-element-to-jsx-string) under the hood.\n\n## Installation\n\n```\nnpm install -D jasmine-expect-jsx\n```\n\n## Setup\n\n### Browser\n\n```html\n\u003cscript src=\"/path/to/jasmine-expect-jsx.js\"\u003e\u003c/script\u003e\n```\n\n### Karma\n\nIntegration is easy with the [karma-jasmine-expect-jsx](https://github.com/smacker/karma-jasmine-expect-jsx) plugin and it provides colored output.\n\nAlso you can just add `'node_modules/jasmine-expect-jsx/dist/jasmine-expect-jsx.js'` to files section of your config.\n\n### Node.js\n\n```javascript\nrequire('jasmine-expect-jsx');\n```\n\n### Jest\n\n1. Add `setupTestFrameworkScriptFile` in `package.json`\n\n```json\n{\n    ...\n    \"jest\": {\n        \"setupTestFrameworkScriptFile\": \"\u003crootDir\u003e/jestSetup.js\"\n    }\n    ...\n}\n```\n\n2. Import `jasmine-expect-jsx` in `setupTestFrameworkScriptFile` file\n\n```javascript\n// jestSetup.js\nrequire('jasmine-expect-jsx');\n```\n\n## Usage\n\nThe following tests are all passing:\n\n### Expect\n\n```javascript\nclass TestComponent extends React.Component {}\n\n// equalJSX\nexpect(\u003cdiv /\u003e).toEqualJSX(\u003cdiv /\u003e);\nexpect(\u003cTestComponent /\u003e).toEqualJSX(\u003cTestComponent /\u003e);\n\nexpect(\u003cdiv /\u003e).not.toEqualJSX(\u003cspan /\u003e);\nexpect(\u003cTestComponent /\u003e).not.toEqualJSX(\u003cspan /\u003e);\n\n// includeJSX\nexpect(\u003cdiv\u003e\u003cspan\u003eHello World!\u003c/span\u003e\u003c/div\u003e).toIncludeJSX(\u003cspan\u003eHello World!\u003c/span\u003e);\nexpect(\u003cTestComponent /\u003e).toIncludeJSX(\u003cSomeSubComponent /\u003e); // assuming \u003cSomeSubComponent /\u003e is rendered by TestComponent's render\n\nexpect(\u003cdiv\u003e\u003cspan\u003eHello World!\u003c/span\u003e\u003c/div\u003e).not.toIncludeJSX(\u003cspan\u003eHello World!\u003c/span\u003e);\nexpect(\u003cTestComponent /\u003e).not.toIncludeJSX(\u003cSomeSubComponent /\u003e); // assuming \u003cSomeSubComponent /\u003e is not rendered by TestComponent's render\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmacker%2Fjasmine-expect-jsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmacker%2Fjasmine-expect-jsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmacker%2Fjasmine-expect-jsx/lists"}