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

classy-test

v1.2.0

Published

Opinionated class based testing framework

Downloads

48

Readme

Classy Test

Build Status

Opinionated class based testing framework.

Features

  • Extensible es6 class test case. Leverage more with less code.
  • Structured tests name syntax - testMyComponentCanAdd.
  • TAP reporting with node-tap
  • Full A+ promise support through bluebird

Install

$ npm install classy-test

Usage

Command Line Interface

$ node node_modules/classy-test/bin/classy-test-cli.js

Exported Module

const ClassyTestRunner = require("classy-test");
new ClassyTestRunner().run();

API

ClassyTestRunner([options])

options

directories

Type: string[] Default: ['test']

Relative paths to all directories that should be searched for test case files.

extension

Type: string (test file extension) Default: '.test.js'

Set the default file extension for your test files.

disableLogging

Type: boolean (disable interal classy test logging) Default: false

This is used for our internal testing to make the logs cleaner. It is exposed has a "quality-of-life" feature.

Examples

Simple

Component

my-project/lib/component.js

"use strict";

class SimpleComponent {
    constructor(numbers) {
        this.numbers = numbers;
    }

    sum() {
        return this.numbers.reduce((a, b) => a + b);
    }

    sort() {
        return this.numbers.sort();
    }
}

module.exports = SimpleComponent;

Test File

my-project/test/component.test.js

"use strict";

const Component = require("../lib/component"),
    classyTest = require("classy-test"),
    assert = require("chai").assert;

// extend base test case.
class ComponentTestCase extends classyTest.BaseTestCase {
    constructor() {
        super();
    }

    // prefix all test functions in your test case with 'test'
    testSum() {
        assert.equal(new Component([1, 2, 3, 4]).sum(), 10);
    }

    testSort() {
        assert.deepEqual(new Component([4, 1, 5, 2, 3]).sort(), [1, 2, 3, 4, 5]);
    }
}

// export an array of test cases you want to run
module.exports = [
    ComponentTestCase
];

Promise Support

"use strict";

const classyTest = require("../index.js"),
    assert = require("chai").assert;

class Invoice {
    // simulate async database interaction
    static getById(id) {
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                if (id) {
                    resolve({
                        id: 123,
                        amount: 100,
                        currency: "USD"
                    });
                } else {
                    reject(new Error("invoice_not_found"));
                }
            }, 200);
        });
    }
}

// test case for all your project needs
class ProjectBaseTestCase extends classyTest.BaseTestCase {
    constructor() {
        super();
    }

    setup() {
        super.setup();
        return this.bootstrapDatabase();
    }

    teardown() {
        super.teardown();
        return this.teardownDatabase();
    }

    bootstrapDatabase() {
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve();
            }, 500)
        });
    }

    teardownDatabase() {
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve();
            }, 500)
        });
    }
}

// Simple test case extended our base project test case
class InvoiceTestCase extends ProjectBaseTestCase {
    constructor() {
        super();
    }

    testGetById() {
        return Invoice.getById(123).then(invoice => {
            assert.deepEqual(invoice, {
                id: 123,
                amount: 100,
                currency: "USD"
            });
        }).catch(console.error);
    }

    testGetByIdError() {
        return Invoice.getById(null).then(() => {
            assert.isFalse(true, "the underlying promise should have failed. This block should never be run");
        }).catch(error => {
            assert.equal(error.message, "invoice_not_found");
        });
    }
}

module.exports = [InvoiceTestCase];

For more examples check here.

Team

John Rake

License

MIT © John Rake