{"id":19669607,"url":"https://github.com/deliciousinsights/chai-jest-diff","last_synced_at":"2025-04-29T00:31:11.890Z","repository":{"id":22297490,"uuid":"95865528","full_name":"deliciousinsights/chai-jest-diff","owner":"deliciousinsights","description":"A plugin to make Chai’s equality assertions (shallow or deep) fail with Jest-like diffs","archived":false,"fork":false,"pushed_at":"2022-03-25T11:15:30.000Z","size":31,"stargazers_count":8,"open_issues_count":4,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-02T05:19:46.770Z","etag":null,"topics":["chai","diff","jest","plugin","test"],"latest_commit_sha":null,"homepage":null,"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/deliciousinsights.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-30T08:12:08.000Z","updated_at":"2022-05-19T14:34:11.000Z","dependencies_parsed_at":"2022-08-07T10:15:27.274Z","dependency_job_id":null,"html_url":"https://github.com/deliciousinsights/chai-jest-diff","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deliciousinsights%2Fchai-jest-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deliciousinsights%2Fchai-jest-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deliciousinsights%2Fchai-jest-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deliciousinsights%2Fchai-jest-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deliciousinsights","download_url":"https://codeload.github.com/deliciousinsights/chai-jest-diff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224142857,"owners_count":17262885,"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","diff","jest","plugin","test"],"created_at":"2024-11-11T17:01:00.235Z","updated_at":"2024-11-11T17:02:01.099Z","avatar_url":"https://github.com/deliciousinsights.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jest-style diffs on Chai equalities\n\nChai’s assertions have a built-in `showDiff` flag, but do not produce the diff themselves; it’s up to the test runner to produce such output.\n\nThe very popular [Mocha](http://mochajs.org/) does that, but Jest doesn’t: its neat diffs are produced internally by its built-in matchers; it doesn’t rely on any sort of metadata to produce diff for third-party assertions.\n\nWhen you start using Jest, if you still prefer Chai for your assertions, you quickly miss Jest’s neat JSON diffs, especially if you used to run tests with Mocha, which produced similar diffs on its own.\n\nThis Chai plugin tries to fix that, piggybacking on Jest’s `jest-diff` and `jest-matcher-utils` for maximum compatibility with Jest’s built-in expectation output.\n\nIt focuses on deep equality testing (through any variation of `.deep.equal` or `.eql`), where such diffs are most relevant.  Because Jest uses diffs even for its `===`-based `.toBe` expectation, it also provides it for shallow `equal` testing, just for consistency’s sake.\n\nOn the other hand, it currently doesn’t provide it for `.property` value testing, unlike Jest’s `.toHaveProperty` expectation.  This seemed to require too much duplication of code between Chai’s internal assertions and this plugin, as there are many edge cases.  We’ll see.\n\n# Usage\n\n```js\nconst chai = require('chai')\nconst chaiJestDiff = require('chai-jest-diff')\n\nchai.use(chaiJestDiff())\n```\n\n# Options\n\nThe plugin factory accepts a boolean argument, `expand`, that mirrors Jest’s `expand` configuration setting, for full-length diffs (instead of close-context diffs).  I couldn’t figure out a way to get this information dynamically from Jest’s exposed API, so you’d have to pass that in manually if you need it.\n\n# License\n\n© 2017 Delicious Insights\n\nThis plugin is provided under the MIT license.  See [`LICENSE.md`](https://github.com/deliciousinsights/chai-jest-diff/blob/master/LICENSE.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeliciousinsights%2Fchai-jest-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeliciousinsights%2Fchai-jest-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeliciousinsights%2Fchai-jest-diff/lists"}