
Product
Redesigned Repositories Page: A Faster Way to Prioritize Security Risk
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
chai-match-pattern
Advanced tools
chai-match-pattern is a Swiss Army Knife for deep matching JSON objects. It is essentially a Chai wrapper for lodash-match-pattern
and detailed documentation can be found there about its pattern matching functionality. This functionality includes deep matching of JSON properties by
checkit
(e.g. _.isURL
, _.isEmail
)lodash
(e.g. _.isObject
, _.isNaN
)# with npm
npm install chai-match-pattern --save-dev
# or with yarn
yarn add --dev chai-match-pattern
In your test file insert
const chai = require('chai');
const chaiMatchPattern = require('chai-match-pattern');
chai.use(chaiMatchPattern);
const _ = chaiMatchPattern.getLodashModule(); // recommend using our lodash extension
Then use patterns to check your JSON with the .matchPattern(pattern)
assertion function. For example
chai.expect({a: 1, b: 'abc'}).to.matchPattern({a: 1, b: _.isString});
See lodash-match-pattern
for way, way more details.
Additionally any of the included isXxxx
functions can be used directly as assertion functions. For example
chai.expect(7.5).isBetween(7, 8);
FAQs
Validates a deep structured JSON pattern
The npm package chai-match-pattern receives a total of 134,282 weekly downloads. As such, chai-match-pattern popularity was classified as popular.
We found that chai-match-pattern demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
Security News
Slopsquatting is a new supply chain threat where AI-assisted code generators recommend hallucinated packages that attackers register and weaponize.
Security News
Multiple deserialization flaws in PyTorch Lightning could allow remote code execution when loading untrusted model files, affecting versions up to 2.4.0.