Registry / testing / test-js

test-js

JSON →
library0.0.4jsnpmunverified

test.js is an extremely lightweight, console API-based unit testing library designed for both Node.js and browser environments. It provides a minimal API for defining test suites and individual tests using simple `[EXPRESSION, EXPECTATION]` arrays. The library aims for simplicity over feature richness, distinguishing itself from more comprehensive testing frameworks. Its latest version, 0.0.4, was released in 2014, indicating that the project is no longer actively maintained. Due to its age, it supports CommonJS modules and global browser scope but lacks modern JavaScript features like ESM, async/await testing, or advanced assertion libraries. Developers seeking a simple, low-overhead solution for basic equality checks in legacy projects might find it useful, but it is not recommended for new projects or environments requiring modern testing paradigms or comprehensive reporting.

npm install test-js
INSTALL
IMPORT
SIG · TEST-JS
T
test-js
testingjavascriptv0.0.4
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.

test
var test = require('test-js');
import test from 'test-js';
This package is CommonJS-only for Node.js environments. ES Modules are not supported.
test.suite
test.suite('My Suite', { /* tests */ });
const suite = test.suite; suite('My Suite', { /* tests */ });
The `test` object is typically used directly from its global or module-imported scope.
test (global)
<script src="test.js"></script> <script> test.suite('My Suite', { /* tests */ }); </script>
import { test } from './test.js';
In browser environments, `test` is exposed as a global variable after the script is loaded. It does not support ES Module imports in the browser.

This quickstart demonstrates how to define and run basic test suites with test.js in both Node.js and browser environments, including examples of passing and failing assertions.

// quickstart.js // This example demonstrates basic usage of the test.js library for simple unit tests. // Run this file with Node.js after 'npm install test-js' or include test.js in an HTML file. var test = require('test-js'); // For Node.js environments // Define a test suite named 'Basic Arithmetic Operations' test.suite('Basic Arithmetic Operations', { // A simple test for addition 'Addition: 1 + 1 should equal 2': [1 + 1, 2], // Another addition test, expecting a different result 'Addition: 5 + 3 should equal 8': [5 + 3, 8], // Test for subtraction 'Subtraction: 10 - 5 should equal 5': [10 - 5, 5], // An intentionally failing test to demonstrate failure output 'Subtraction: 7 - 2 should NOT equal 4 (expected to fail)': [7 - 2, 4], // This will fail // Test for multiplication 'Multiplication: 3 * 4 should equal 12': [3 * 4, 12], // Test for division 'Division: 10 / 2 should equal 5': [10 / 2, 5] }); // Define another suite for boolean logic test.suite('Boolean Logic Tests', { 'True is true': [true, true], 'False is false': [false, false], 'NOT true is false': [!true, false], 'AND operator: true && true is true': [true && true, true], 'OR operator: false || true is true': [false || true, true] }); // To run this in Node.js: // 1. Save as e.g., 'my-tests.js' // 2. npm install test-js // 3. node my-tests.js // // To run in a browser: // 1. Download test.js // 2. <script src="test.js"></script> // 3. <script src="my-tests.js"></script> // 4. Open the HTML file in a browser and check the console.
Debug
Known issues
breakingProject is abandoned. The last release (0.0.4) was in 2014, and there is no active development or maintenance. Users should not expect bug fixes, security updates, or new features.
fix
Migrate to an actively maintained testing framework like Jest, Mocha, Vitest, or QUnit for modern projects.
affects: >=0.0.1
gotchaNo support for modern JavaScript features. test.js predates ES Modules, async/await, and modern assertion libraries, leading to verbose or impossible testing patterns for contemporary codebases.
fix
Consider modern alternatives like Jest, Mocha, or Vitest for projects using ES Modules or asynchronous code.
affects: >=0.0.1
gotchaLimited assertion capabilities. The framework only supports simple equality checks with [EXPRESSION, EXPECTATION] pairs, lacking advanced assertions (e.g., toContain, toMatchObject, toThrow) or mock/spy functionality.
fix
For more robust testing, integrate a dedicated assertion library or switch to a framework with built-in rich assertions.
affects: >=0.0.1
Errors
Common errors & fixes
ReferenceError: test is not defined
Attempting to use 'test' in a browser environment without including the <script src="test.js"></script> tag, or before the script has fully loaded.
fix
Ensure 'test.js' is loaded via a script tag before calling any 'test' methods in the browser. Place your test script after the library script.
ReferenceError: require is not defined
Attempting to use CommonJS 'require' in a browser environment, an ES Module context, or without a Node.js-like environment.
fix
In a Node.js CommonJS environment, ensure 'var test = require('test-js');' is at the top of your file. In a browser, use the global 'test' object after loading the script via <script> tag. This library does not support ES Modules.
TypeError: test.suite is not a function
The 'test' object was not correctly loaded, or a different global variable named 'test' is overshadowing the library's export.
fix
Verify the correct import/script loading method for your environment (CommonJS 'require' for Node.js, <script> tag for browser). Check for conflicting global variables if in a browser environment.
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
test-js — npm install test-js · libregistry