urun: Minimal Test Runner
urun is a minimal, file-based test runner for Node.js environments. Currently at version 0.0.8, its development appears to be abandoned, with the last significant update to its `package.json` occurring 12 years ago and the last commit 13 years ago. It was designed for simplicity, running `test-*.js` files by default within a specified directory, providing a progress indication, and showing detailed output only for failing tests unless `verbose` mode is enabled. Its key differentiators include its extremely lightweight footprint and direct CommonJS `require` based usage, eschewing complex configuration or modern CLI tools. It offers basic reporter options like 'BashReporter' and 'BashTapReporter' for TAP-compliant output.
Common errors
-
SyntaxError: Cannot use import statement outside a module
cause Attempting to use ES module `import` syntax (`import urun from 'urun';`) for the `urun` package in an environment where it's treated as a CommonJS module.fixUse CommonJS `require` syntax: `const urun = require('urun');` -
TypeError: require(...) is not a function
cause Attempting to destructure `urun` as a named export, e.g., `const { urun } = require('urun');`, when the package's main export is the function itself (a 'default' CommonJS export).fixImport the module as a single function: `const urun = require('urun');` -
No tests found matching pattern
cause The default test file pattern `/test-.+\.js$/` or a custom `include` regex does not match any files in the specified directory, or `__dirname` points to an incorrect location.fixEnsure test files follow the `test-*.js` naming convention or adjust the `include` option: `urun(__dirname, { include: /.+Test\.js$/ });` Also, verify `__dirname` or the path passed to `urun` points to the correct directory containing your tests.
Warnings
- gotcha The `urun` package has not been updated in over a decade. The latest commit on GitHub is 13 years old, and the `package.json` was last updated 12 years ago. This means it is no longer actively maintained and may have compatibility issues with modern Node.js versions or lack security updates.
- breaking Given its age, `urun` is strictly a CommonJS module. Attempting to import it using ES module `import` syntax (`import urun from 'urun';`) in a modern Node.js environment configured for ESM will result in a `SyntaxError`.
- gotcha The package is extremely minimal and lacks features common in modern test runners, such as built-in watch mode, parallel test execution, mocking utilities, advanced assertion libraries (it relies on Node's built-in `assert`), or rich reporting beyond basic console and TAP output.
Install
-
npm install urun -
yarn add urun -
pnpm add urun
Imports
- default export (function)
import urun from 'urun';
const urun = require('urun'); urun(__dirname); - direct execution
require('urun').run(__dirname);require('urun')(__dirname); - with options
require('urun')(__dirname, { verbose: true, include: /.+Test\.js$/ });
Quickstart
const urun = require('urun');
const path = require('path');
// Create a dummy test file
require('fs').writeFileSync(path.join(__dirname, 'test-example.js'), `
const assert = require('assert');
module.exports = {
'should pass a basic assertion': function() {
assert.strictEqual(1, 1, '1 should equal 1');
},
'should fail a basic assertion': function() {
assert.strictEqual(1, 2, '1 should equal 2');
}
};
`);
// Run tests in the current directory with verbose output
console.log('Running tests with urun...');
process.on('exit', (code) => {
if (code === 0) {
console.log('All tests passed.');
} else {
console.log('Some tests failed. Exit code:', code);
}
// Clean up dummy test file
require('fs').unlinkSync(path.join(__dirname, 'test-example.js'));
});
urun(__dirname, { verbose: true });