0.4.1 • Published 5 months ago

expect-color v0.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

expect-color

Make assertions on normalized color

Installation

npm install expect-color

Usage

Jest

In you test-setup-file add:

import "expect-color";

With @jest/globals

In you test-setup-file add:

import "expect-color/jest-globals";

With Vitest

In you test-setup-file add:

import "expect-color/vitest";

With another Jest-compatible expect

import * as matchers from "expect-color/matchers";
import { expect } from "my-test-runner/expect";

expect.extend(matchers);

Standalone

import { assertSameColor } from "expect-color/assert";

assertSameColor("red", "red");

Usage

it("compares colors", () => {
  // Same color in same color space
  expect("rgb(255, 0, 255)").toBeColor("fuchsia");

  // Same color in different color space
  expect("fuchsia").toEqualColor("hsl(300, 100%, 50%)");

  expect({ borderColor: "rgb(255, 0, 255)" }).toEqual({
    borderColor: expect.toBeColor("fuchsia"),
  });
});
0.4.1

5 months ago

0.4.0

5 months ago

0.0.0-development

5 months ago

0.2.0

5 months ago

0.1.2

5 months ago

0.1.1

5 months ago

0.1.0

5 months ago