Registry / testing / node-test

node-test

JSON →
library1.4.6jsnpmunverified

node-test is a simple, asynchronous test runner for Node.js, currently at version 1.4.6. Its core design principles emphasize concurrent test execution, the absence of global testing primitives like `describe` or `it`, and the ability to run test files directly via `node` without a dedicated CLI. It supports asynchronous tests through Promises or Node.js-style callbacks and extends the core `assert` module with additional assertions. The library prioritizes direct code execution and debuggability by not forking test processes by default, aiming to make testing feel like writing any other application code. Release cadence is infrequent, with the last major update several years ago, indicating a mature but less actively developed project. It differentiates itself by its minimalist, no-globals approach.

npm install node-test
INSTALL
IMPORT
SIG · NODE-TEST
N
node-test
testingjavascriptv1.4.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Suite
const Suite = require('node-test');
import { Suite } from 'node-test';
The package primarily uses CommonJS exports; direct ESM import via `import` statements is not officially supported or documented in v1.x.
suite.test
suite.test('My Test', t => { /* ... */ });
Tests are defined as methods on a `Suite` instance, not as global functions.
t.equal
t.equal(actual, expected, 'message');
`t` is the assertion object passed to each test function, extending Node.js's built-in `assert` module.

Demonstrates creating a test suite, defining asynchronous tests with Promises and callbacks, synchronous assertions, and using skip/todo features.

'use strict'; const Suite = require('node-test'); function funcReturnsPromise() { return Promise.resolve(2); } function funcWithCallback(cb) { setTimeout(cb, 10); } const suite = new Suite('My Example Suite'); suite.test('Test 1 - Promise resolution', t => { return funcReturnsPromise() .then(result => { t.equal(result, 2, 'Promise should resolve to 2'); }); }); suite.test('Test 2 - Callback for async operation', (t, done) => { funcWithCallback(() => { t.ok(true, 'Callback should be invoked'); done(); }); }); suite.test('Test 3 - Synchronous assertion', t => { const value = 1 + 1; t.equal(value, 2, '1 + 1 should equal 2'); }); suite.skip('Test 4 - Skipped test', t => { t.fail('This test should not run'); }); suite.todo('Test 5 - Future work');
Debug
Known issues
gotchanode-test does not expose global testing functions like `describe()`, `it()`, or `test()`. All tests must be defined as methods on a `Suite` instance.
fix
Migrate existing tests from global `describe`/`it` syntax to `new Suite('Name')` and `suite.test('Name', ...)`.
affects: >=1.0.0
gotchaAsynchronous tests must explicitly signal completion either by returning a Promise or by calling the `done()` callback provided to the test function. Failure to do so will result in the test silently passing or timing out.
fix
Ensure async test functions return a Promise or accept `done` as a second argument and call `done()` when the asynchronous operation completes.
affects: >=1.0.0
gotchaBy default, `node-test` runs tests concurrently. Tests should be atomic and not depend on global state or the order of execution. If tests share state or have dependencies, they might produce flaky results.
fix
Design tests to be independent and atomic. Use `beforeEach` and `afterEach` hooks for setup/teardown if state management is unavoidable, or explicitly configure serial test execution for a suite when order matters.
affects: >=1.0.0
gotchaThe package's primary export mechanism is CommonJS (`require`). While Node.js supports ESM, `node-test` v1.x may not correctly handle `import` syntax without additional transpilation or specific Node.js configuration for CJS interoperability.
fix
Use `const Suite = require('node-test');` for importing the library. If using ESM in your project, ensure proper CommonJS interoperability settings are configured or consider using a different test runner with native ESM support.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: describe is not defined
Attempting to use global `describe` or `it` functions from other test frameworks (e.g., Mocha, Jest).
fix
Refactor tests to use `new Suite('Name')` and `suite.test('Test Name', ...)` as `node-test` does not provide global test primitives.
AssertionError: 1 === 2
A built-in assertion (e.g., `t.equal`) failed because the actual value did not match the expected value.
fix
Review the test logic and the expected output. Adjust the assertion or the code under test to ensure correctness.
Test timed out
An asynchronous test was executed but did not complete within the default timeout period, usually because its Promise was not resolved/rejected or its `done()` callback was not called.
fix
Ensure all asynchronous operations within a test either return a Promise or call the `done()` callback upon completion. Check for unhandled promises or forgotten `done()` calls.
Upgrade
Version history
1.4.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
node-test — npm install node-test · libregistry