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 🙏

© 2026 – Pkg Stats / Ryan Hefner

test-assert-lite

v0.1.0

Published

A lightweight node:test and node:assert compatible library for browsers.

Readme

test-assert-lite

npm version gzip size

A lightweight node:test and node:assert compatible library for browsers.

  • From node:test: describe / it, test with t.test() subtests, before / after, skip and todo
  • From node:assert: assert and strict, with ok, equal, deepStrictEqual, throws, rejects, match and more
  • The same test file runs in both Node.js and the browser
  • Under 32KB minified, under 11KB gzipped, no dependencies
  • tacli and its browser runners run node:test test suites unchanged. They map node:test to this library

SYNOPSIS

BDD style with describe and it:

import {strict as assert} from "test-assert-lite/assert"
import {describe, it} from "test-assert-lite/test"

const parseQuery = (search) => Object.fromEntries(new URLSearchParams(search))
const buildQuery = (params) => new URLSearchParams(params).toString()

describe("buildQuery() from an object", () => {
    it("round-trips through parseQuery()", () => {
        const params = {q: "cat", page: "2"}
        assert.deepEqual(parseQuery("?" + buildQuery(params)), params)
    })
    it("appends to a URL", () => {
        const url = new URL("https://example.com/search")
        url.search = buildQuery({q: "cat"})
        assert.equal(url.href, "https://example.com/search?q=cat")
    })
})

See test-assert-lite.d.ts for the supported API.

The same test suite runs under node, and in a browser:

node --test test/query.test.mjs

# https://www.npmjs.com/package/test-assert-cli
tacli --serve test/query.test.mjs

# https://www.npmjs.com/package/webdriver-js-cli
webdriver-js --test test/query.test.mjs

# https://www.npmjs.com/package/playwright-js-cli
chromium-js --test test/query.test.mjs

test with subtests:

import {strict as assert} from "test-assert-lite/assert"
import {test} from "test-assert-lite/test"

test("URLSearchParams", async (t) => {
    const params = new URLSearchParams("a=1&b=2")
    await t.test("reads a key", () => {
        assert.equal(params.get("a"), "1")
    })
    await t.test("is null for a missing key", () => {
        assert.equal(params.get("c"), null)
    })
})

BROWSER MODULE

Tests can also go straight into a page, with no build step.

The minified build is an ES module. An import map maps the package's name to it on a CDN.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/test-assert-cli/htdocs/styles/test-assert-lite.css">
<script type="importmap">
{
    "imports": {
        "test-assert-lite": "https://cdn.jsdelivr.net/npm/test-assert-lite/dist/test-assert-lite.min.js",
        "test-assert-lite/test": "https://cdn.jsdelivr.net/npm/test-assert-lite/exports/test.js",
        "test-assert-lite/assert": "https://cdn.jsdelivr.net/npm/test-assert-lite/exports/assert.js",
        "test-assert-lite/process": "https://cdn.jsdelivr.net/npm/test-assert-lite/exports/process.js",
        "test-assert-lite/session": "https://cdn.jsdelivr.net/npm/test-assert-lite/exports/session.js"
    }
}
</script>
<div id="output"></div>
<script type="module">
    import {describe, it} from "test-assert-lite/test"
    import {strict as assert} from "test-assert-lite/assert"
    import {run, session} from "test-assert-lite/session"

    // The report goes to console.log by default. Here it is rendered as HTML in the page.
    // session() comes before the first test is declared, and run() closes it.
    session({
        reporter: "html",
        output: html => document.getElementById("output").insertAdjacentHTML("beforeend", html),
    })

    describe("URL", () => {
        it("keeps the host", () => {
            assert.equal(new URL("https://example.com/a?b").host, "example.com")
        })
    })

    // run() starts every test registered so far and resolves once they are reported
    run().then(result => console.log(result.success ? "PASS" : "FAIL"))
</script>

Bundled tests in a page

Or bundle the suites with the library into one ES module, so the page needs no import map. An entry imports the suites and calls run().

// test/browser.mjs
import "./query.test.mjs"
import "./params.test.mjs"
import {run} from "test-assert-lite/session"

run().then(result => console.log(result.success ? "PASS" : "FAIL"))
// rollup.config.mjs
import {nodeResolve} from "@rollup/plugin-node-resolve"

export default {
    input: "test/browser.mjs",
    output: {
        file: "htdocs/scripts/tests.js",
        format: "es",
    },
    plugins: [nodeResolve()],
    treeshake: false,
}
<script type="module" src="./scripts/tests.js"></script>

The report goes to the console. The same bundle runs under node unchanged.

SEE ALSO

  • https://www.npmjs.com/package/test-assert-lite
  • https://www.npmjs.com/package/test-assert-cli
  • https://www.npmjs.com/package/webdriver-js-cli
  • https://www.npmjs.com/package/playwright-js-cli
  • https://github.com/kawanet/test-assert-lite
  • https://nodejs.org/api/test.html
  • https://nodejs.org/api/assert.html