Registry / testing / mocha-banner

mocha-banner

JSON →
library1.1.2jsnpmunverified

Mocha Banner is a utility specifically designed for the Mocha testing framework, offering a visual enhancement to test output. It generates a terminal-wide banner displaying the name of the current test or test suite before its execution, aiding in readability and navigation through extensive test logs. The current stable version is 1.1.2, released in March 2018. The project's release cadence has been infrequent since its initial development. Its primary differentiator is providing clear, prominent visual demarcation between tests, which can significantly improve the debugging and review process, especially in environments where many tests run sequentially. It builds upon the `terminal-banner` package for its core rendering capabilities and is typically integrated as a development dependency.

npm install mocha-banner
INSTALL
IMPORT
SIG · MOCHA-BANNER
M
mocha-banner
testingjavascriptv1.1.2
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.

register
require('mocha-banner').register()
import { register } from 'mocha-banner'
This package is CommonJS-only and relies on direct 'require()'. It does not provide an ESM export, so 'import' statements will fail in pure ESM environments.

Demonstrates how to globally enable the terminal banner for Mocha tests, and how to scope it to specific test suites.

// In your Mocha test setup file (e.g., test/setup.js or directly in spec files) // ensure this runs before your actual test suites. // To enable banners for all tests: require('mocha-banner').register(); // Example suite describe('My Application Features', () => { it('should handle user login successfully', () => { // Test logic here console.log('Running login test...'); }); describe('Advanced User Operations', () => { // To enable banners only for this suite and its children, place register() inside: // require('mocha-banner').register(); it('should allow users to update their profile', () => { // Test logic here console.log('Running profile update test...'); }); }); });
Debug
Known issues
gotchaThe package is CommonJS-only and relies on direct `require()`. Attempting to import it using ESM `import` syntax in a pure ESM environment will result in a runtime error unless a CommonJS-to-ESM bridge is used.
fix
Use `require('mocha-banner').register()` instead of `import { register } from 'mocha-banner'`.
affects: >=1.0.0
gotchaThe package has not been updated since March 2018 (v1.1.2). While it remains functional for its specific purpose, it may not be actively maintained for compatibility with newer Node.js versions, Mocha versions, or to address potential security vulnerabilities in its transitive dependencies.
fix
Consider reviewing the dependency tree for known vulnerabilities or evaluating alternatives if long-term maintenance and up-to-date compatibility are critical. Test thoroughly with your specific Node.js and Mocha versions.
affects: >=1.1.2
gotchaThe banner output can introduce visual clutter in CI logs or environments where terminal output is strictly parsed. This might interfere with CI/CD reporting tools or log parsing scripts that expect a specific output format.
fix
Conditionally enable the banner based on environment variables (e.g., `if (process.env.CI !== 'true') { require('mocha-banner').register(); }`) or use a different Mocha reporter for CI environments.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: require(...) is not a function
Attempting to use ESM 'import' syntax with a CommonJS-only module, or misinterpreting the module's export.
fix
Ensure you are using `require('mocha-banner').register()` as the package exports a function directly, not an object with named exports for 'register'.
SyntaxError: Cannot use import statement outside a module
Using 'import' syntax for 'mocha-banner' in a script that is executed as CommonJS (e.g., without '"type": "module"' in package.json or a '.mjs' extension).
fix
Convert the 'import' statement to `require('mocha-banner').register()` or ensure your project is properly configured for ESM and consider a CommonJS wrapper if necessary.
Banner not appearing in test output.
The `register()` call is placed incorrectly, perhaps after the tests have already started or in a scope that is not executed before the relevant `describe` or `it` blocks.
fix
Ensure `require('mocha-banner').register()` is called at the very beginning of your test setup file or before any `describe` blocks if you want it globally. If scoping to a suite, ensure it's inside that `describe` block.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies
terminal-bannerrequiredCore dependency for rendering the terminal banners.
mochaoptionalRuntime dependency for integrating with the Mocha test runner.
Agent activity
2 hits · last 30 days
node
2
Resources
mocha-banner — npm install mocha-banner · libregistry