
Product
Introducing Module Reachability: Focus on the Vulnerabilities That Matter
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
🃏🎨
A bundle of Jest matchers for testing and asserting colors
Testing colors with Jest is not simple. It should be as easy as .toBeColor
jest-color aims to add additional matchers to Jest's default ones that does just that
If you've come here to help contribute - Sweet! Thanks! Take a look at the contributing and read the Code of Conduct docs as a way of getting started!
With npm:
npm install -D jest-color
With yarn:
yarn add -D jest-color
Add jest-color
to your Jest setupFilesAfterEnv
configuration. See for help
"jest": {
"setupFilesAfterEnv": ["jest-color"]
}
All matchers described below have asymmetric variants. Example:
test("symmetric vs asymmetric", () => {
expect("#7db2ceff").toBeColor(125, 178, 206);
expect("#7db2ceff").toEqual(expect.color(125, 178, 206));
});
Accepts anything that color
accepts and compares them to one another. It must be the exact same color.
expect("#7db2ceff").toBeColor(125, 178, 206); // true
expect("#72510e").toBeColor(114, 81, 14, 1); // true
expect([157, 204, 97]).toBeColor("#9dcc61"); // true
expect("hwb(60, 3%, 60%)").toBeColor("rgb(102, 102, 8)"); // true
expect("#cccc0866").toBeColor("hwb(60, 3%, 20%, 0.4)"); // true
expect("hsla(114, 60%, 39%, 0.32)").toBeColor([52, 159, 40, 0.32]); // true
expect("#7db2caaa").not.toBeColor(125, 178, 202); // true
The asymmetric variant of .toBeColor
.
expect("#7db2ceff").toEqual(expect.color(125, 178, 206)); // true
expect("#72510e").toEqual(expect.color(114, 81, 14, 1)); // true
expect([157, 204, 97]).toEqual(expect.color("#9dcc61")); // true
expect("hwb(60, 3%, 60%)").toEqual(expect.color("rgb(102, 102, 8)")); // true
expect("#cccc0866").toEqual(expect.color("hwb(60, 3%, 20%, 0.4)")); // true
expect("hsla(114, 60%, 39%, 0.32)").toEqual(expect.color([52, 159, 40, 0.32])); // true
expect("#7db2caaa").toEqual(expect.not.color(125, 178, 202)); // true
Also accepts anything that color
accepts. It compares them using THE POWER OF SCIENCE CIEDE2000 and if the Delta E is less than 1 it returns true.
The asymmetric variant of .toBeIndistinguishableFrom
.
expect([50, 158, 38]).toEqual(expect.indistinguishableFrom(49, 155, 37)); // true
expect([217, 223, 214]).toEqual(
expect.indistinguishableFrom("rgb(216, 222, 215)"),
); // true
expect("hwb(110, 84%, 13%)").toEqual(
expect.indistinguishableFrom("hwb(111, 84%, 13%)"),
); // true
FAQs
A bundle of Jest matchers for testing and asserting colors
The npm package jest-color receives a total of 6,117 weekly downloads. As such, jest-color popularity was classified as popular.
We found that jest-color 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
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
Product
Socket is introducing a new way to organize repositories and apply repository-specific security policies.
Company News
Socket’s acquisition of Coana brings best-in-class reachability analysis to application security teams globally, cementing Socket’s position as the leader in software supply chain security. The news comes as Socket has seen over 300% year-over-year revenue growth over the past year with customers including Anthropic, Figma, OpenAI, and Vercel.