Gathering detailed insights and metrics for chai-subset
Gathering detailed insights and metrics for chai-subset
Gathering detailed insights and metrics for chai-subset
Gathering detailed insights and metrics for chai-subset
npm install chai-subset
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
82 Stars
87 Commits
20 Forks
42 Watching
1 Branches
45 Contributors
Updated on 11 Apr 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-17%
53,524
Compared to previous day
Last week
2%
334,318
Compared to previous week
Last month
21.5%
1,397,808
Compared to previous month
Last year
14.4%
11,360,394
Compared to previous year
"containSubset" object properties matcher for Chai assertion library
npm install --save-dev chai-subset
common.js
1var chai = require('chai'); 2var chaiSubset = require('chai-subset'); 3chai.use(chaiSubset);
in your spec.js
1var obj = { 2 a: 'b', 3 c: 'd', 4 e: { 5 foo: 'bar', 6 baz: { 7 qux: 'quux' 8 } 9 } 10}; 11 12expect(obj).to.containSubset({ 13 a: 'b', 14 e: { 15 baz: { 16 qux: 'quux' 17 } 18 } 19}); 20 21// or using a compare function 22expect(obj).containSubset({ 23 a: (expectedValue) => expectedValue, 24 c: (expectedValue) => expectedValue === 'd' 25}) 26 27// or with 'not' 28expect(obj).to.not.containSubset({ 29 g: 'whatever' 30});
Also works good with arrays and should
interface
1var list = [{a: 'a', b: 'b'}, {v: 'f', d: {z: 'g'}}]; 2 3list.should.containSubset([{a:'a'}]); //Assertion error is not thrown 4list.should.containSubset([{a:'a', b: 'b'}]); //Assertion error is not thrown 5 6list.should.containSubset([{a:'a', b: 'bd'}]); 7/*throws 8AssertionError: expected 9[ 10 { 11 "a": "a", 12 "b": "b" 13 }, 14 { 15 "v": "f", 16 "d": { 17 "z": "g" 18 } 19 } 20] 21to contain subset 22[ { a: 'a', b: 'bd' } ] 23*/
and with assert
interface
1assert.containSubset({a: 1, b: 2}, {a: 1});
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 19/30 approved changesets -- score normalized to 6
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More