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

bestunit.js

v0.1.1

Published

To be the best unit test framework for node.js

Readme

To be the best unit test framework for node.js .

ChangeLog

v0.1.x

  1. Replace setUp and tearDown with before(Each) and after(Each).
  2. Setup before* and after* for a directory by adding a .js file with the same name.
  3. The -dd/--debug option.
  4. Only Node 4.x supported.

Installation

npm install -g bestunit.js

Run all tests

bu -h
bu -d /directory1/tests/placed -d /directory2/tests/placed
bu -f /the/test/case
bu -f /the/test/case -tc testCaseName

-f will be ignored if -d is given.

Promise

  1. Simplest assertion style.
  2. No more tests will be executed after assertion failed.
  3. All after* functions of the failed TestCase and its TestGroup hierarchy will be called after assertion failed.
  4. Feel free to save anything in the context and share then among all tests.

TestGroup and TestCase

BU only defines TestCase and TestGroup which includes TestCases. A TestGroup can be a javascript object or a directory.And it can be nested. You can define 4 methods for a TestGroup, which are before,after, beforeEach, afterEach. before/after will be called before/after running TestGroup. beforeEach/afterEach will be called before/after each TestCase/TestGroup in the TestGroup.

Assertion

You can require any assertion 3rd-party module you like or just use intrinsics.

Assertion

How to

Simplest

Touch a js source file looks like:

module.exports = {
	simpleCase1: function(t) {
		t.done();
	},
  simpleCase2: function(t) {
		t.done();
	},
};

DO NOT forget to call t.done() when the case is done.

t is an object and you can save anything into it to share them among all tests.

Nested

module.exports = {
	simpleCase1: function(t) {
		t.done();
	},

	testGroup1: {
		testGroup3: {
			tg3C1: function(t) {
				t.done();
			}
		},

		tg1Case1: function(t) {
			t.done();
		},
	},

	simpleCase2: function(t) {
		t.done();
	},

	testGroup2: {
		tg2Case1: function(t) {
			t.done();
		},
	},
};

With SetUps and TearDowns

module.exports = {
	before: function(t) {
    // Be called before any tests and beforeEach.
		t.done();
	},
	after: function(t) {
    // Be called after all tests and afterEach.
		t.done();
	},
	beforeEach: function(t) {
    // Be called before running g1, t and t2
		t.done();
	},
	afterEach: function(t) {
    // Be called after running g1, t and t2
		t.done();
	},
	g1: {
		t: function(t) {
			t.done();
		},
		t2: function(t) {
			t.done();
		}
	},
	t: function(t) {
		t.done();
	},
	t2: function(t) {
		t.done();
	}
};

Directory

Example

before* and after* of case.js will be applied to TestGroup defined by directory case.

Example

Example1

Example2