npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

jest-color

v0.1.0

Published

A bundle of Jest matchers for testing and asserting colors

Downloads

20,309

Readme

🃏🎨

A bundle of Jest matchers for testing and asserting colors

Build Status version downloads MIT License PRs Welcome

Problem

Testing colors with Jest is not simple. It should be as easy as .toBeColor

Solution

jest-color aims to add additional matchers to Jest's default ones that does just that

Contributing

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!


Installation

With npm:

npm install -D jest-color

With yarn:

yarn add -D jest-color

Setup

Jest >v24

Add jest-color to your Jest setupFilesAfterEnv configuration. See for help

"jest": {
  "setupFilesAfterEnv": ["jest-color"]
}

Asymmetric matchers

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));
});

API

.toBeColor(object)

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

expect.color(color)

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

.toBeIndistinguishableFrom(color)

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.

expect.indistinguishableFrom(color)

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

LICENSE

MIT