Skip to main content
meow:test is the API behind meow test. Import it in any *.test.* / *.spec.* file — there’s nothing to install, and each file runs in its own deterministic isolate.
import { test, expect } from "meow:test";

test("adds numbers", () => {
  expect(2 + 2).toBe(4);
});

test()

function test(name: string, fn: () => void): void;
Registers a test. meow test runs every registered test in the file, in order, and reports each as or .

expect()

function expect<T>(actual: T): Expect<T>;

interface Expect<T> {
  toBe(expected: T): void;       // Object.is identity / primitive equality
  toEqual(expected: T): void;    // deep structural equality
  toBeNull(): void;
  toBeDefined(): void;
  toBeTruthy(): void;
  toBeFalsy(): void;
  toThrow(): void;               // the actual value must be a function
  readonly not: Expect<T>;       // inverts the next matcher
}

Matchers

toBe(expected)
Passes when Object.is(actual, expected) — identity for objects, value equality for primitives.
toEqual(expected)
Passes on deep structural equality — recursively compares arrays and plain objects.
toBeNull()
Passes when the value is exactly null.
toBeDefined()
Passes when the value is not undefined.
toBeTruthy() / toBeFalsy()
Passes on JavaScript truthiness / falsiness.
toThrow()
Calls the actual value (which must be a function) and passes if it throws.
not
Inverts the matcher that follows: expect(x).not.toBe(y).

Examples

example.test.ts
import { test, expect } from "meow:test";

test("identity vs structural equality", () => {
  expect(1 + 1).toBe(2);
  expect({ a: 1, b: [2, 3] }).toEqual({ a: 1, b: [2, 3] });
});

test("negation", () => {
  expect("meow").not.toBe("woof");
  expect([]).not.toBeNull();
});

test("truthiness and definedness", () => {
  expect("non-empty").toBeTruthy();
  expect(0).toBeFalsy();
  expect({}).toBeDefined();
});

test("throwing", () => {
  expect(() => JSON.parse("{not json}")).toThrow();
  expect(() => 42).not.toThrow();
});
A failing matcher throws with a readable message that the runner surfaces under the test name:
  ✗ adds numbers
    expect(5).toBe(4)
Because every test file runs in a deterministic isolate (frozen clock, seeded RNG, pinned timezone), assertions on time- or random-derived values are stable. See Testing and Determinism.

Run your tests

The meow test command, discovery rules, and output.