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

@wellers/testarray

v1.1.6

Published

Functions to augment testing with Node.js Test Runner module.

Downloads

21

Readme

Overview

Node.js v18 introduced the experimental Test Runner module under node:test.

Writing tests which check the same function but with different inputs often results in writing the same tedious boilerplate code.

import test from "node:test";
import { strictEqual } from "assert";

// function to test
function addOne(num) {
	return num + 1;
}

test("given num is 1, should return 2", (t) => {
	strictEqual(addOne(1), 2);
});

test("given num is 2, should return 3", (t) => {
	strictEqual(addOne(2), 3);
});

test("given num is 3, should return 4", (t) => {
	strictEqual(addOne(3), 4);
});

Defining your test cases using testArray will help reduce the boilerplate code produced when writing multiple test() statements.

import { strictEqual } from "assert";
import testArray from "@wellers/testarray";

// function to test
function addOne(num) {
	return num + 1;
}

const tests = [
	{
		name: 'given num is 1, should return 2',
		args: {
			num: 1,
			result: 2
		}
	},
	{
		name: 'given num is 2, should return 3',		
		args: {
			num: 2,
			result: 3
		}
	},
	{
		name: 'given num is 3, should return 4',
		args: {
			num: 3,
			result: 4
		}
	}
];

testArray(tests, test => {
	strictEqual(addOne(test.num), test.result);
});

More involved examples are available here.

API

testArray(tests, fn) - Given an array of tests, execute a function on each test's args.

  • tests - object[] - Array of tests.
    • name - string - Name of the test.
    • timeout - number - Timeout in ms for this specific test.
    • before - function or async function - Execute a function prior to execution of the test.
    • after - function or async function - Execute a function after the execution of the test.
    • concurrency - number - The number of tests that can be run at the same time. Default: 1.
    • only - boolean - Only execute this test. --test-only command-line option is required when running tests to use this option.
    • skip - boolean - Skip this test.
    • todo - boolean or string - If truthy, the test marked as TODO. If a string is provided, that string is displayed in the test results as the reason why the test is TODO.
    • args - object, function or async function - Definition of the test data which will be passed to the fn.
  • fn - function(test) or async function(test) - Receives the test args returned on test.