+{"_id":"chai-better-shallow-deep-equal","_rev":"1-b8a427c9d0246f29e189c33a0c9231e5","name":"chai-better-shallow-deep-equal","dist-tags":{"latest":"1.0.0"},"versions":{"0.1.0":{"name":"chai-better-shallow-deep-equal","version":"0.1.0","description":"Chai shallowDeepEqual replacement that wraps Unexpected","main":"lib/chai-better-shallow-deep-equal.js","scripts":{"coverage":"nyc --reporter=lcov --reporter=text mocha","lint":"eslint . && prettier --check '**/*.js'","test":"mocha"},"keywords":["chai","chai-plugin","objects","assertions","testing","shallow","deep"],"author":{"name":"Alex J Burke","email":"alex@alexjeffburke.com"},"repository":{"type":"git","url":"git+https://github.com/alexjeffburke/chai-better-shallow-deep-equal.git"},"license":"MIT","dependencies":{"unexpected":"^11.13.0"},"devDependencies":{"chai":"^4.2.0","coveralls":"^3.0.9","eslint":"^6.8.0","eslint-config-prettier":"^6.10.0","eslint-config-standard":"^14.1.0","eslint-plugin-import":"^2.20.1","eslint-plugin-mocha":"^6.3.0","eslint-plugin-node":"^11.0.0","eslint-plugin-promise":"^4.2.1","eslint-plugin-standard":"^4.0.1","mocha":"^7.1.0","nyc":"^15.0.0","prettier":"^1.19.1","unexpected-snapshot":"^1.0.0"},"gitHead":"8a603af753b50dcad9602ecaed0acd1f7e77d1cf","bugs":{"url":"https://github.com/alexjeffburke/chai-better-shallow-deep-equal/issues"},"homepage":"https://github.com/alexjeffburke/chai-better-shallow-deep-equal#readme","_id":"chai-better-shallow-deep-equal@0.1.0","_nodeVersion":"10.19.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-8qVUP7gsvc4L6HTd4SQ8GOPHbGAXqyPNq4n0PwjbYHfTY0XLqqCPpOPFyMhWB30+zIt0ux551E/KFI7eVasQTQ==","shasum":"a13f7f555494dfee3266cd2a8ae7ba27dc0b4941","tarball":"https://registry.npmjs.org/chai-better-shallow-deep-equal/-/chai-better-shallow-deep-equal-0.1.0.tgz","fileCount":4,"unpackedSize":7200,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeap8QCRA9TVsSAnZWagAAhlAP/0TUsA2z3W3DQ1RRQl7M\njyJpmOXgDm8huPJJccP3JSqVwtZeC334JsuOv+rC9xZD00wzxXdo5t4ZZtaq\n9Gy+dXhRZVApkQqDQ2FP1WWTbBQ3AXMmn+jlCxXOP3DKqm+CTVhAJKBDKWfl\nRmO9awFwMxq+BZNt303p+Xc/5T8Qi+70l/pBLSgs/kAH8Qlm2Gwd4fsnjVCR\n0CWIV2SLZRugkuteXwTaqAxfeWZKsHE9rNTUG5JubrlR2xVarGhRxuJq/JTj\n1rBibTN5VPjek5rrndvGpCm259eydCk3y17csl+z4LZ+eJlzlAEGmqcPH+Aq\nDW38it0SWiFkYD4lgxCGzcfnopBrdY1kI6KpWV5+8cX80cig+o+9ToW1diw6\nyFEfh4CMIGVkIT9Rwp9P6AkrIPya93DhfpvbPfoy/fKdGnjo2luw22HU+daE\nTtOImJ68UnORqZT8A7s4CK1imVdM24UWI5FDPk9vLMM1TCW1yNu+7hSQri+J\nCXqhJ52zSLRDl/rH3kyv/KXe4q99UOWUun01tNY+1Jchv7Uay06vAmz0RwVO\nu/QswY8AcZ3OqY0rWFvrPxPPjSxdonyLbdz6ZRpWOfmEg1M8YgPNfYq0lPod\nGeged9RbwRgtjTH24SYAZHhWgGYEreinq4ZrQB6kU6XD57c4f9x5hUyptuxc\nOKIC\r\n=6LGW\r\n-----END PGP SIGNATURE-----\r\n"},"maintainers":[{"name":"alexjeffburke","email":"alex@alexjeffburke.com"}],"_npmUser":{"name":"alexjeffburke","email":"alex@alexjeffburke.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-better-shallow-deep-equal_0.1.0_1584045840449_0.6696779166281432"},"_hasShrinkwrap":false},"1.0.0":{"name":"chai-better-shallow-deep-equal","version":"1.0.0","description":"Chai shallowDeepEqual replacement that wraps Unexpected","main":"lib/chai-better-shallow-deep-equal.js","scripts":{"coverage":"nyc --reporter=lcov --reporter=text mocha","docs":"evaldown --inplace ./README.md","lint":"eslint . && prettier --check '**/*.js'","test":"mocha","version":"npm run docs && git add README.md"},"keywords":["chai","chai-plugin","objects","assertions","testing","shallow","deep"],"author":{"name":"Alex J Burke","email":"alex@alexjeffburke.com"},"repository":{"type":"git","url":"git+https://github.com/alexjeffburke/chai-better-shallow-deep-equal.git"},"license":"MIT","dependencies":{"unexpected":"^11.13.0","unexpected-map":"^2.0.0","unexpected-set":"^3.0.0"},"devDependencies":{"chai":"^4.2.0","chai-better-shallow-deep-equal":"file:./","coveralls":"^3.0.9","eslint":"^6.8.0","eslint-config-prettier":"^6.10.0","eslint-config-standard":"^14.1.0","eslint-plugin-import":"^2.20.1","eslint-plugin-mocha":"^6.3.0","eslint-plugin-node":"^11.0.0","eslint-plugin-promise":"^4.2.1","eslint-plugin-standard":"^4.0.1","evaldown":"^1.2.3","mocha":"^7.1.0","nyc":"^15.0.0","prettier":"~1.19.1","unexpected-snapshot":"^1.0.0"},"gitHead":"16ba1ce3fe35a5807a247dc0ee587e43e3f91a03","bugs":{"url":"https://github.com/alexjeffburke/chai-better-shallow-deep-equal/issues"},"homepage":"https://github.com/alexjeffburke/chai-better-shallow-deep-equal#readme","_id":"chai-better-shallow-deep-equal@1.0.0","_nodeVersion":"10.19.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-F4ertY2MS+TnGquUW4qnX/1uMhDdn2yC6uKPNu6aZGe/OGbNYoilSTA56pPllv8fD8JnkcJh8YLJPLJAh+9qFQ==","shasum":"fedca5565ed5f160ee00aca8de063f7cf6f0974a","tarball":"https://registry.npmjs.org/chai-better-shallow-deep-equal/-/chai-better-shallow-deep-equal-1.0.0.tgz","fileCount":4,"unpackedSize":8816,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfP7BcCRA9TVsSAnZWagAAIKAP/3oLHb7Fdmk6v73BeWib\nUx4VxSETf+UFlP1FmrdxN3aLq7n6ZMr9PVBzTtKVuKD+jYT/ROxi2OPkHr4x\nnCoj9KH/jQa/5eRQFaqGaGlmatNSy55vg0bmoBQ2Gr7BTeT6TtWE8XL6JHQS\nl9SWf6J/yj3Pt+emF8L31b8N1eGbStpliTTKBNhq2DBlo6avRTXrzZdk3p6R\na3MJMhyZSjbU0aLAkL41Cyd4B1MZ6PC3iJVf+1XDFbyntf30Q1xak7yaMQiI\n0BUQzpMUCALm6hcHjfmm49z/5blty35bdRUq9atxSDYyM0IXJLbC35EcpHYH\nFMw8/8EcvCQG0TggekQwAao3QE1UBfVCDE+PB6UYfWAzkd7P38iHpQgdfKNK\njoT6YHGpJgTZ7aB9AyxcwTeipKoEYP9F1shNLXLnGmcPZCUyPj5DRpeaWCXA\ngQB0az3DY0IjODaTSh2TnkRQQw0R8saafLtUm/TgqKofx7LjEOVjthN2+oZy\nwxEMulPSof2xQEklD/cAWkRy+CcDtdArkRko+2sOY4CUnkmCnw6rEMqrdOOX\nobB1lEXnXeAMkSTKs1ZDpmLduRj8oghyr7/PVcSXGx3GAVGZRAzDoKWBG9mh\n/r1Izc5hlD46zG582XNfME9Z5lfpmsCH+3lZzrn3lOG/qc6tKT9vqF5n4jnx\nu+T2\r\n=w8RK\r\n-----END PGP SIGNATURE-----\r\n"},"maintainers":[{"name":"alexjeffburke","email":"alex@alexjeffburke.com"}],"_npmUser":{"name":"alexjeffburke","email":"alex@alexjeffburke.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-better-shallow-deep-equal_1.0.0_1598009436165_0.8236132660300008"},"_hasShrinkwrap":false}},"time":{"created":"2020-03-12T20:44:00.448Z","0.1.0":"2020-03-12T20:44:00.602Z","modified":"2020-08-21T11:30:38.556Z","1.0.0":"2020-08-21T11:30:36.266Z"},"maintainers":[{"name":"alexjeffburke","email":"alex@alexjeffburke.com"}],"description":"Chai shallowDeepEqual replacement that wraps Unexpected","homepage":"https://github.com/alexjeffburke/chai-better-shallow-deep-equal#readme","keywords":["chai","chai-plugin","objects","assertions","testing","shallow","deep"],"repository":{"type":"git","url":"git+https://github.com/alexjeffburke/chai-better-shallow-deep-equal.git"},"author":{"name":"Alex J Burke","email":"alex@alexjeffburke.com"},"bugs":{"url":"https://github.com/alexjeffburke/chai-better-shallow-deep-equal/issues"},"license":"MIT","readme":"# (Better) Chai Shallow Deep Equal plugin\n\nThis module provides a drop-in replacement `shallowDeepEqual`\nassertion for [chai](https://www.chaijs.com) that uses strict\nsemantics and an intuitive output diff.\n\n[](https://www.npmjs.com/package/chai-better-shallow-deep-equal)\n[](https://travis-ci.org/alexjeffburke/chai-better-shallow-deep-equal)\n[](https://coveralls.io/r/alexjeffburke/chai-better-shallow-deep-equal?branch=master)\n\nUnder the hood the library wraps the [Unexpected](https://unexpected.js.org)\nlibrary, specifically making use of the structural\n[\"to satisfy\"](https://unexpected.js.org/assertions/any/to-satisfy/) assertion.\n\n## Use\n\nOnce installed the plugin can be simply imported and used as a plugin:\n\n```js\nconst chai = require(\"chai\");\nconst expect = chai.expect;\n\nchai.use(require(\"chai-better-shallow-deep-equal\"));\n```\n\nAn additional `.shallowDeepEqual()` assertion is then available for use and\non error an informative diff will be printed:\n\n\n```js\nexpect({ foo: true, bar: 0 }).to.shallowDeepEqual({ foo: true, bar: 1 });\n```\n\n```output\nexpected { foo: true, bar: 0 } to satisfy { foo: true, bar: 1 }\n\n{\n foo: true,\n bar: 0 // should equal 1\n}\n```\n\n## Support for ES6 types\n\nThe plugin has support for structurally comparing both Map and Set objects:\n\n```js\nexpect(\n new Map([\n [\"foo\", 1],\n [\"bar\", false]\n ])\n).to.shallowDeepEqual(\n new Map([\n [\"foo\", 1],\n [\"bar\", true]\n ])\n);\n```\n\n```output\nexpected Map([ ['foo', 1], ['bar', false] ])\nto satisfy Map([ ['foo', 1], ['bar', true] ])\n\nMap([\n ['foo', 1,]\n ['bar',\n false // should equal true\n ]\n])\n```\n\n```js\nexpect(new Set([\"foo\", \"baz\"])).to.shallowDeepEqual(\n new Set([\"foo\", \"bar\"])\n);\n```\n\n```output\nexpected Set([ 'foo', 'baz' ]) to satisfy Set([ 'foo', 'bar' ])\n\nSet([\n 'foo',\n 'baz' // should be removed\n // missing 'bar'\n])\n```\n\n## Customisation\n\n### Adding types\n\nSometimes it can be beneficial to identify certain types within\nthe test suite - perhaps to customise their display or to treat\nthem otherwise differently. This can be achieved by using the\n`addType()` API:\n\n```js\nconst chaiBetterShallowDeepEqual = require(\"chai-better-shallow-deep-equal\");\n\nchaiBetterShallowDeepEqual.addType({\n name: \"CustomDate\",\n base: \"date\",\n identify: obj => obj && obj._isCustomDate\n});\n```\n\nIn the example above, we are trying to single out certain objects\nthat occur within a hypthetical test suite that use custom dates\nby checking whether they have an \"isCustomDate\" property.\n\nGiven our definition of the `identify()` method above, when the\nplugin encounters such objects it will think of them as `CustomDate`\nand be aware that they extend the behavior of the builtin date type.\n\nThis API accepts the same options as the Unexpected\n[addType()](https://unexpected.js.org/api/addType/) method.\nPlease consult the link for more detailed description.\n\n### Custom Matching\n\nWith the availablity of custom types are in the picture, one common\ndesire is to allow customising the way those identified types are\nmatched.\n\nBy default only alike types are compared, but suppose that within\nour tests we want to allow comparing any `CustomDate` object against\na, ISO time string.\n\nLet's stick with the exmaple from our earlier hypothetical - we can\ndefine allowing the comparison using the `addMatch()` API:\n\n```js\nchaiBetterShallowDeepEqual.addMatch({\n leftType: \"CustomDate\",\n rightType: \"string\",\n handler: (lhs, rhs) => [lhs.toISOString(), rhs]\n});\n```\n\nWhat we've defined here is when we see a `CustomDate` being compared\nto a string, to instead first convert it to an ISO string and then do\nthe comparison. In the test suite, the effect is to allow expecations\nto be defined in a way that is much more easily read:\n\n```js\nconst fooDate = new Date(1583947016326);\n\nexpect({ fooDate }).to.shallowDeepEqual({\n fooDate: \"2020-03-11T17:16:56.326Z\"\n});\n```\n\n```output\nexpected { fooDate: new Date('Wed, 11 Mar 2020 17:16:56.326 GMT') }\nto satisfy { fooDate: '2020-03-11T17:16:56.326Z' }\n\n{\n fooDate: new Date('Wed, 11 Mar 2020 17:16:56.326 GMT') // should equal '2020-03-11T17:16:56.326Z'\n}\n```\n","readmeFilename":"README.md"}
0 commit comments