Registry / testing / tad
library0.0.6jsnpmunverified

TAD (Test All) is a minimal JavaScript test suite designed for straightforward unit testing, providing a streamlined experience for developers. It allows organizing tests into a dedicated `_test_` directory, corresponding to main application files. The current stable version is 3.1.1, released in August 2023, with the last major version (3.0.0) released in August 2019. The package generally follows a maintenance cadence with occasional bug fixes and breaking changes tied to Node.js version support or internal feature enhancements. Key differentiators include its simple file-based test discovery, automatic argument injection (`t` for tested module, `a` for assertions, `d` for async completion), and flexible support for synchronous, asynchronous, and nested tests. It extends the UncommonJS assert API with convenience aliases, aiming to reduce boilerplate in test functions. Its primary usage is via a command-line interface, but it also offers a programmatic API for integrating into build systems.

npm install tad
INSTALL
IMPORT
SIG · TAD
T
tad
testingjavascriptv0.0.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.

run
const runTests = require('tad');
import runTests from 'tad';
The 'run' function is the programmatic entry point for executing tests; 'tad' is primarily a CommonJS package. It is used to execute test files, not to be imported into individual test files.
Test File (Anonymous Export)
module.exports = function (t, a, d) { /* Synchronous or asynchronous tests here */ };
export default function (t, a, d) { /* ... */ };
This is the standard CommonJS pattern for defining a single test suite in a file. 't', 'a', and 'd' are arguments provided by the 'tad' runner based on the function signature; they are not imported from 'tad'.
Test File (Named Exports)
exports['My First Test'] = function (t, a) { /* ... */ }; exports['My Second Async Test'] = function (t, a, d) { /* ... */ };
export const myTest = function (t, a) { /* ... */ };
Multiple tests can be grouped within a single file using named `exports` in CommonJS. The runner will execute each exported function as a separate test.

This quickstart demonstrates how to set up and programmatically run `tad` tests for a simple module, including synchronous, asynchronous, and nested test structures using CommonJS exports.

const runTests = require('tad'); const path = require('path'); // Create a dummy module to be 't' (tested module) require('fs').writeFileSync(path.join(__dirname, 'my-module.js'), 'module.exports = { greet: (name) => `Hello, ${name}!` };'); // Create a test file const testFilePath = path.join(__dirname, 'test', 'my-module-test.js'); require('fs').mkdirSync(path.dirname(testFilePath), { recursive: true }); require('fs').writeFileSync(testFilePath, ` exports['Greeting functionality'] = function (t, a) { a(t.greet('World'), 'Hello, World!', 'should greet correctly synchronously'); }; exports['Async greeting'] = function (t, a, d) { setTimeout(() => { a(t.greet('AsyncUser'), 'Hello, AsyncUser!', 'should greet correctly asynchronously'); d(); }, 50); }; module.exports['Nested tests'] = function (t, a) { a(true, true, 'top-level nested test part'); return { 'Inner sync test': function () { a(false, false, 'inner synchronous test works'); }, 'Inner async test': function (d) { setTimeout(() => { a(1, 1, 'inner async test works'); d(); }, 20); } }; }; `); // Run tests programmatically async function executeTadTests() { console.log('Running TAD tests programmatically...'); try { const results = await runTests(testFilePath, { // Options can be passed here }); console.log('TAD test run complete. Results:', results); } catch (error) { console.error('TAD test run failed:', error); process.exit(1); } } executeTadTests();
tad --version
Debug
Known issues
breakingIn `tad` v3.0.0, objects returned by test functions that possess a `then` method are no longer automatically processed as promises. This change implies a shift in how asynchronous test results are handled, potentially requiring explicit `d()` calls or different promise management.
fix
Ensure asynchronous tests explicitly call the `d()` callback to signal completion, or manage promises internally without relying on `tad`'s automatic thenable processing for return values.
affects: >=3.0.0
breaking`tad` v2.0.0 and above dropped support for older Node.js versions (v0.10.16 and below). Running on unsupported environments may lead to unexpected errors or failures.
fix
Upgrade your Node.js runtime to a supported version (Node.js >=0.12 is specified in `package.json`).
affects: >=2.0.0
breakingIn `tad` v1.0.0, the CLI executable was renamed from `bin/tad` to `bin/tad.js`. Additionally, test files starting with a dot (`.`) are now ignored during automatic test discovery.
fix
Update scripts to use `bin/tad.js` or `npm test` if configured. Rename any test files prefixed with `.` to ensure they are discovered by the runner.
affects: >=1.0.0
gotchaAsynchronous test functions, which declare the `d` (done) argument, *must* call `d()` to signal completion. Failing to do so will result in the test hanging indefinitely or timing out without reporting a clear failure.
fix
Ensure `d()` is called at the end of every asynchronous test path, including within callbacks or promise chains, to properly terminate the test.
affects: >=0.1.0
gotcha`tad` infers which arguments to pass (`t` for module, `a` for assert, `d` for done) based on the test function's declared signature. Declaring an argument that is not used by the test (e.g., `d` in a synchronous test) can lead to confusion; however, *omitting* `d` from an async test will prevent it from being treated as asynchronous.
fix
Declare only the arguments truly needed by your test function. For asynchronous tests, always include `d` in the signature.
affects: >=0.1.0
gotcha`tad` expects test files to reside in a `_test_` folder relative to the module they are testing, or within a main `_test_` folder at the project root for general discovery. Misplacing test files can lead to `tad` not discovering and running them.
fix
Organize test files according to `tad`'s convention: `_test_/<module-name>-test.js` for module-specific tests or a top-level `_test_` directory for general tests, and ensure they are discoverable via the CLI path.
affects: >=0.1.0
Errors
Common errors & fixes
Test function argument 'd' was expected to be called but was not.
An asynchronous test function (one that declares `d` in its signature) completed execution without calling the `d()` callback, indicating it never signaled completion.
fix
Ensure all execution paths in your asynchronous test function explicitly call `d()` once the test logic is complete.
No tests found in specified path.
`tad` could not locate any `module.exports` or `exports` test functions within the files in the provided path, or the files themselves were not found/accessible.
fix
Verify the path passed to `bin/tad.js` (or programmatic `runTests`) is correct, test files adhere to the `_test_` folder convention, and test functions are properly `module.exports` or `exports` in a CommonJS format.
ReferenceError: exports is not defined (or similar for 'module')
Attempting to run `tad` test files (which use CommonJS `exports`/`module.exports`) in an ECMAScript Module (ESM) environment (e.g., a file with `type: "module"` in `package.json` or `.mjs` extension).
fix
Ensure your test files are interpreted as CommonJS modules by either using the `.js` extension without `type: "module"` in `package.json`, or configure your environment to specifically treat test files as CommonJS.
Upgrade
Version history
0.0.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

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