jest-color
🃏🎨
A bundle of Jest matchers for testing and asserting colors
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":
Asymmetric matchers
All matchers described below have asymmetric variants. Example:
;
API
.toBeColor(object)
Accepts anything that color
accepts and compares them to one another. It must be the exact same color.
; // true; // true; // true; // true; // true; // true not; // true
expect.color(color)
The asymmetric variant of .toBeColor
.
; // true; // true; // true; // true; // true; // true ; // 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
.
; // true; // true; // true