+{"_id":"@thiscode/chai-subset","_rev":"1-64cd0be311e3492688f96a34c9fe0dab","name":"@thiscode/chai-subset","dist-tags":{"latest":"1.6.2"},"versions":{"1.6.1":{"name":"@thiscode/chai-subset","version":"1.6.1","description":"Object properties matcher for Chai","main":"lib/chai-subset.js","scripts":{"test":"istanbul cover node_modules/mocha/bin/_mocha","coveralls":"cat ./coverage/lcov.info | coveralls"},"repository":{"type":"git","url":"git+https://github.com/thiscode/chai-subset.git"},"keywords":["chai","chai-plugin","objects","subset","contains","plugin","containSubset","deep","like","match","similar","includes","superset"],"author":{"name":"Andrii Shumada","email":"eagleeyes91@gmail.com"},"contributors":[{"name":"Robert Herhold","email":"reherhold@gmail.com"},{"name":"Thomas Miliopoulos","email":"github@thiscode.com"}],"license":"MIT","bugs":{"url":"https://github.com/debitoor/chai-subset/issues"},"homepage":"https://github.com/debitoor/chai-subset","devDependencies":{"@debitoor/eslint-config-debitoor":"1.2.0","chai":"3.5.0","coveralls":"2.11.16","istanbul":"0.4.5","mocha":"3.2.0","mocha-eslint":"3.0.1"},"engines":{"node":">=4"},"gitHead":"b09c93398aefbbd2ba190ec401d76e245bf0a439","_id":"@thiscode/chai-subset@1.6.1","_nodeVersion":"12.16.3","_npmVersion":"6.14.5","dist":{"integrity":"sha512-ph7s8HCr8JKgmnMzMxf6tiAWLUF5IO3QNHlowGd/R48sxjb874jEr/1dIGlsVHtpn2yoyKs/g9XkfNlGg7rk8Q==","shasum":"de02881bff0271fe6b4e107abc39487893a2523b","tarball":"https://registry.npmjs.org/@thiscode/chai-subset/-/chai-subset-1.6.1.tgz","fileCount":4,"unpackedSize":8254,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnJMqCRA9TVsSAnZWagAA9KEP/0c4T+enqUml0XG2UISz\naNyuzR1MIJaKI2Z003tPV6u1Ka0tVbTmaM+28LBkd3GL9NzHqH38GugcQU0C\n5KPkR5NECVuQlNPF4+B36HyjsTENYwhTufTQQ89cmg/m7BtveGWtwTNpZGs3\nNhkR0MGSRvCTdt1MkpF7ptlFNXf8MyY3WE+RUFvneTVhQWkKNtit1KIof4+6\nyNUQavzSGrlgKz++4y2EERX+Cg1NiYlrWi6P6g/4pwZqDEebh6yPHaUP7KWy\nZnQ126Kiqww0V/4j2WZ3scIOEFjsASALTku9lLsX+0YV2EWkHUK54ryyfNwE\nsVSPkv7aE2aWKNF+eWOpnodivtcaKbyO7CSbjrLD83P7+e+owE6ryVlwK7fx\nHE6+FklPe6z+PhQGOoTEz4A5buelL/D9u31ZliLg/KYUtMNHNQG7Yi5p0btM\nYMo+x5tLlOhUyZ0cc93gZhcoMB8ptPRXuwSnHyFj23QSH3aUqT81YDAaLCb0\naerpsioph8wkMh4YbNrn/9tdY8i42Ua/HqtTIawDS46SRCrPGoI0ZeRfveNa\nXNdzAKZHmkQ2Mgnfq7/NLWFJ/cn+BEgxZv7p4quRj9vCyVyxnMoO3o3+aRRQ\nJGp66zILGTiuoNp33NnbYVm3RilPW4C12Ixhwzla3BAgIDnT8njcOSfEXYTc\n0As1\r\n=1Trb\r\n-----END PGP SIGNATURE-----\r\n"},"maintainers":[{"name":"tom27","email":"codecoupler@onbinel.com"}],"_npmUser":{"name":"tom27","email":"codecoupler@onbinel.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-subset_1.6.1_1604096810026_0.16728947068721634"},"_hasShrinkwrap":false},"1.6.2":{"name":"@thiscode/chai-subset","version":"1.6.2","description":"Object properties matcher for Chai","main":"lib/chai-subset.js","scripts":{"test":"istanbul cover node_modules/mocha/bin/_mocha","coveralls":"cat ./coverage/lcov.info | coveralls"},"repository":{"type":"git","url":"git+https://github.com/thiscode/chai-subset.git"},"keywords":["chai","chai-plugin","objects","subset","contains","plugin","containSubset","deep","like","match","similar","includes","superset"],"author":{"name":"Andrii Shumada","email":"eagleeyes91@gmail.com"},"contributors":[{"name":"Robert Herhold","email":"reherhold@gmail.com"},{"name":"Thomas Miliopoulos","email":"github@thiscode.com"}],"license":"MIT","bugs":{"url":"https://github.com/debitoor/chai-subset/issues"},"homepage":"https://github.com/debitoor/chai-subset","devDependencies":{"@debitoor/eslint-config-debitoor":"1.2.0","chai":"3.5.0","coveralls":"2.11.16","istanbul":"0.4.5","mocha":"3.2.0","mocha-eslint":"3.0.1"},"engines":{"node":">=4"},"gitHead":"f0e5977b80ead82dbe2e5a4d68ff56128bdfcd82","_id":"@thiscode/chai-subset@1.6.2","_nodeVersion":"12.16.3","_npmVersion":"6.14.5","dist":{"integrity":"sha512-N3om5Vl/y+3cKkMIrFoR5bmbU3smmr0GCPAydkclcB80dqID3excQxB6Hp7iM+OzEO1Ng5cN7rdrrh58Se+VvQ==","shasum":"2ede1b29c8b7330ad5dc7982563c27b1c93fcbf2","tarball":"https://registry.npmjs.org/@thiscode/chai-subset/-/chai-subset-1.6.2.tgz","fileCount":4,"unpackedSize":8834,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnJT/CRA9TVsSAnZWagAA66MP/j+graWuGq1RZ+mjrZGx\nNy9P7WE9Q6AxBTHq5yZ39W2msGAdkluIpBN89HlyozRVONalJT5gzWCySt/r\nFuzFgdn+UjFOcYcgorwGz8S5yefmPLXfO7DNWvF71gQxeWe1AqAJmkx1c5BD\na+Z3rJlAiduqGu4Casck1HBe+HS2ytqMSvOw9vycAxe8Es8GYNE9ON6GJ1H/\nc8OQgz9/mQMFVyHq+WzNacZhK2pzsOlFFNlRrEKvEq6TDuTLAwI7mUcbgxqn\nhHL/oBLkkW5zHFYJ6fSbnakGUBKNXM2HzyE+CrE4gErTYCbkp5gq4/NBsmKS\nzYEekKOt1GG3nwGjx1WxhpowUlrOT5VOL0CUVn7b+pFQWkEbCLr5puPF2Kiu\naFatfCK+pwwbbkYzYEMu2JjktV3We6GapXnzwclljYNoS72mzrMbOplM7Miw\nZKLrg/gKQMT/ZNa7UKJ0QJYjkCIku9CUsi7sbGCaAgA38C5aMGDX44T48H47\nCnU4nGz001Q7khLj4dKVADqeN+LjGWmvm8JPqAglptlPkPSfD9bO/RQQjYhT\nQThhGy8Y7AjNO5FGUO/hBvH3PymQm4MPea9GpmY1R6BZ0hq+hwlU1Ixk4N0m\no1i6te6smbwhJUje5wy3zjFGE/SxahJA2QsBMyKmiFzj84hIBPQm2KqrfSZE\n+Yby\r\n=X2LM\r\n-----END PGP SIGNATURE-----\r\n"},"maintainers":[{"name":"tom27","email":"codecoupler@onbinel.com"}],"_npmUser":{"name":"tom27","email":"codecoupler@onbinel.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-subset_1.6.2_1604097279184_0.02749486317941141"},"_hasShrinkwrap":false}},"time":{"created":"2020-10-30T22:26:49.760Z","1.6.1":"2020-10-30T22:26:50.240Z","modified":"2020-10-30T22:34:41.594Z","1.6.2":"2020-10-30T22:34:39.295Z"},"maintainers":[{"name":"tom27","email":"codecoupler@onbinel.com"}],"description":"Object properties matcher for Chai","homepage":"https://github.com/debitoor/chai-subset","keywords":["chai","chai-plugin","objects","subset","contains","plugin","containSubset","deep","like","match","similar","includes","superset"],"repository":{"type":"git","url":"git+https://github.com/thiscode/chai-subset.git"},"contributors":[{"name":"Robert Herhold","email":"reherhold@gmail.com"},{"name":"Thomas Miliopoulos","email":"github@thiscode.com"}],"author":{"name":"Andrii Shumada","email":"eagleeyes91@gmail.com"},"bugs":{"url":"https://github.com/debitoor/chai-subset/issues"},"license":"MIT","readme":"Fork Information\n================\n\nI was searching for an subset test which can handle arrays in any order. `chai-subset` was the one that worked. But the messages are meaningless. Like this one:\n\n```text\nexpected { Object (key1, key2, ...) } to contain subset { Object (key1) }\n```\n\nIt would be better to show what exactky the difference is. I have tried some other libraries, but no one was suitable for me:\n\n- chai-deep-match, chai-samsam: Cannot check array of objects in any order and no detailed diff (just like chai-subset saying something like that an object expecting another object, no different values shown)\n- chai-better-shallow-deep-equal: Cannot check array of objects in any order and very messy assertion error message\n- chai-match-pattern: Could work, but cannot use patterns with partial notation \"...\" to reach my goal\n- chai-shallow-deep-equal: Cannot check array of objects in any order, but very nice assertion error which display only the (first) relevant difference\n\nSo I tried to take on the coding pattern from \"chai-shallow-deep-equal\" and integrate it into \"chai-subset\".\n\nNow the assertion messages should be better readable like:\n\n```text\nExpected to have \"some_value\" but got \"other_value\" at path \"/key1/key2\"\n```\n\n@thiscode/chai-subset\n=====================\n\n\"containSubset\" object properties matcher for [Chai](http://chaijs.com/) assertion library\n\nInstallation\n===========\n\n`npm install --save-dev @thiscode/chai-subset`\n\nUsage\n=====\n\ncommon.js\n```js\nvar chai = require('chai');\nvar chaiSubset = require('@thiscode/chai-subset');\nchai.use(chaiSubset);\n```\n\nin your spec.js\n```js\nvar obj = {\n\ta: 'b',\n\tc: 'd',\n\te: {\n\t\tfoo: 'bar',\n\t\tbaz: {\n\t\t\tqux: 'quux'\n\t\t}\n\t}\n};\n\t\nexpect(obj).to.containSubset({\n\ta: 'b',\n\te: {\n\t\tbaz: {\n\t\t\tqux: 'quux'\n\t\t}\n\t}\n});\n\n// or using a compare function\nexpect(obj).containSubset({\n\ta: (expectedValue) => expectedValue,\n\tc: (expectedValue) => expectedValue === 'd'\n})\n\n// or with 'not'\nexpect(obj).to.not.containSubset({\n\tg: 'whatever'\n});\n```\n\nAlso works good with arrays and `should` interface\n```js\nvar list = [{a: 'a', b: 'b'}, {v: 'f', d: {z: 'g'}}];\n\nlist.should.containSubset([{a:'a'}]); //Assertion error is not thrown\nlist.should.containSubset([{a:'a', b: 'b'}]); //Assertion error is not thrown\n\nlist.should.containSubset([{a:'a', b: 'bd'}]); \n/*throws\nAssertionError: expected\n[\n {\n \"a\": \"a\",\n \"b\": \"b\"\n },\n {\n \"v\": \"f\",\n \"d\": {\n \"z\": \"g\"\n }\n }\n]\nto contain subset \n[ { a: 'a', b: 'bd' } ]\n*/\n```\n\nand with `assert` interface\n```js\nassert.containSubset({a: 1, b: 2}, {a: 1});\n```\n","readmeFilename":"README.md"}
0 commit comments