{"id":14989716,"url":"https://github.com/debitoor/chai-subset","last_synced_at":"2025-04-05T07:06:29.964Z","repository":{"id":18608119,"uuid":"21813326","full_name":"debitoor/chai-subset","owner":"debitoor","description":"\"containSubset\" object properties matcher for Chai","archived":false,"fork":false,"pushed_at":"2023-05-19T11:33:28.000Z","size":42,"stargazers_count":82,"open_issues_count":21,"forks_count":20,"subscribers_count":41,"default_branch":"master","last_synced_at":"2025-03-29T06:07:24.336Z","etag":null,"topics":["chai","chai-subset","javascript","properties-matcher"],"latest_commit_sha":null,"homepage":"http://chaijs.com/plugins/chai-subset/","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/debitoor.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-14T08:55:22.000Z","updated_at":"2024-04-11T12:52:27.000Z","dependencies_parsed_at":"2024-06-18T12:40:17.829Z","dependency_job_id":"81b65305-94b7-4295-95a0-781a7dfd6ca4","html_url":"https://github.com/debitoor/chai-subset","commit_stats":{"total_commits":72,"total_committers":11,"mean_commits":6.545454545454546,"dds":0.375,"last_synced_commit":"5c943ada7356c23d3bd9b04ba2b230ec8a5eebac"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debitoor%2Fchai-subset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debitoor%2Fchai-subset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debitoor%2Fchai-subset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debitoor%2Fchai-subset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/debitoor","download_url":"https://codeload.github.com/debitoor/chai-subset/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299832,"owners_count":20916190,"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-subset","javascript","properties-matcher"],"created_at":"2024-09-24T14:18:48.961Z","updated_at":"2025-04-05T07:06:29.944Z","avatar_url":"https://github.com/debitoor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"chai-subset [![npm version](https://badge.fury.io/js/chai-subset.svg)](https://badge.fury.io/js/chai-subset) [![Build Status](https://travis-ci.org/debitoor/chai-subset.svg?branch=master)](https://travis-ci.org/debitoor/chai-subset) [![devDependency Status](https://david-dm.org/debitoor/chai-subset/dev-status.svg)](https://david-dm.org/debitoor/chai-subset#info=devDependencies) [![Coverage Status](https://coveralls.io/repos/debitoor/chai-subset/badge.svg?service=github)](https://coveralls.io/github/debitoor/chai-subset) [![NSP Status](https://nodesecurity.io/orgs/debitoor/projects/eb6fec04-2b26-4462-b4ff-08d952da3065/badge)](https://nodesecurity.io/orgs/debitoor/projects/eb6fec04-2b26-4462-b4ff-08d952da3065)\n===========\n\n\"containSubset\" object properties matcher for [Chai](http://chaijs.com/) assertion library\n\nInstallation\n===========\n\n`npm install --save-dev chai-subset`\n\nUsage\n=====\n\ncommon.js\n```js\nvar chai = require('chai');\nvar chaiSubset = require('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) =\u003e expectedValue,\n\tc: (expectedValue) =\u003e 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebitoor%2Fchai-subset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdebitoor%2Fchai-subset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebitoor%2Fchai-subset/lists"}