Skip to main content


Common assertion functions, especially useful for testing

Works with
This package works with Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Browsers
JSR Score
a week ago
deno add @std/assert
import * as mod from "@std/assert";
npx jsr add @std/assert
import * as mod from "@std/assert";
yarn dlx jsr add @std/assert
import * as mod from "@std/assert";
pnpm dlx jsr add @std/assert
import * as mod from "@std/assert";
bunx jsr add @std/assert
import * as mod from "@std/assert";

A library of assertion functions. If the assertion is false an AssertionError will be thrown which will result in pretty-printed diff of failing assertion.

This module is browser compatible, but do not rely on good formatting of values for AssertionError messages in browsers.

import { assert } from "@std/assert/assert";

assert("I am truthy"); // Doesn't throw
assert(false); // Throws `AssertionError`
Built and signed on
GitHub Actions
View transparency log