vbardales / chai-properties Goto Github PK
View Code? Open in Web Editor NEWProperties matcher for chai that assert values have all the same attributes and values without asserting strict object equality.
Properties matcher for chai that assert values have all the same attributes and values without asserting strict object equality.
let obj = {a: 'value one', b: 'value2'}
expect(obj).to.have.properties(['a','b'])
Hi,
Thanks for this very nice chai plugin! IMHO, this functionality so useful, it should be integrated into the chai proper.
But here is the issue I've ran into this issue when using it. Currently, if the object under test has a property X that is itself an object, the assertion will only check that properties of expected.X are a subset of properties in actual.X. This may be dangerous as the users may be expecting the full comparison, and be missing hidden problems such as this one:
chai.expect({permissions: {limited: true, admin: true}})
.to.have.properties({permissions: {limited: true}});
It would be nice to perform full equality rather than the subset check on the members of the expected properties, either by default or as a selectable option.
Thanks!
Chai 4 has been out for a while but chai-properties requires Chai <4.
chai-properties
module is using the lodash's older version which is having vulnerability issue.
I tried raising a PR for the same. But I don't have access to create a branch in this repo.
Can we please have this change in package.json
?
"dependencies": {
"lodash": "~4.17.11"
}
Negated functions (subject.should.not.have.properties({ a: '1' });
) aren't implemented but are shown in the README.
Hi, and thanks for this.
I'm just starting with chai and couldn't believe it's not in the default assertions, TBH.
If you could register your lib on bower it could be helpful.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.