New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mini-unit

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mini-unit

xUnit style test cases, suites, and runner for Node's assert module.

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

MiniUnit

xUnit style test cases, suites, and runner for Node's assert module. Inspired by Ruby's MiniTest::Unit.

MiniUnit is only intended to help you structure your tests, it is expected you'll be using it with the Node.js assert module for assertions.

Usage

// require MiniUnit and Node's assert module
var MiniUnit = require("mini-unit");
var assert = require("assert");

// require the module under test
var MyModule = require("./../lib/my-module");

// create and name a test case
var tc = new MiniUnit.TestCase("MyModule");

// run before each test
tc.setup = function () {
    this.adder = new MyModule.adder();
};

// run after each test
tc.teardown = function () {
    this.adder.reset();
};

// test methods must be named 'test' followed by at least one character.
tc.testAddition = function () {
    var a = 2,
        b = 2,
        result,
    
    result = this.adder.add(a, b)
    
    assert.equal(result, 4);
};

// if the file being run is the current file, then run the tests, otherwise
// export the test case
if (require.main === module) {
    MiniUnit.run(tc);
} else {
    module.exports = tc;
}

Running a suite of test cases

var MiniUnit = require("mini-unit");
var testCases = [
    "./foo",
    "./bar"
].map(function (path) {
    return require(path);
});

MiniUnit.runSuit(testCases);

Keywords

xUnit

FAQs

Package last updated on 12 Feb 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts