Registry / testing / mocha-web

mocha-web

JSON →
library2.6.1jsnpmunverified

Runs Mocha tests in Chromium via Playwright, bundling test files with esbuild. Current stable version is 2.6.1, released quarterly with dependency upgrades and bug fixes. Unlike alternatives like karma or jest-electron, it integrates directly with esbuild for fast bundling and esbuild config support, and supports both ESM and CJS tests. Requires Mocha, Playwright Chromium, and esbuild as peer dependencies. Node >=20 required.

npm install mocha-web
INSTALL
IMPORT
SIG · MOCHA-WEB
M
mocha-web
testingjavascriptv2.6.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default (CLI)
npx mocha-web "test/**/*.spec.js"
mocha-web
CLI usage; no programmatic API exported.
default export
import mochaWeb from 'mocha-web'
const mochaWeb = require('mocha-web')
Package does not export any JS symbols; only a CLI binary. Importing is a mistake unless you are using a bundler that resolves the main field.
mocha-web cli
mocha-web --version
Run as a command-line tool; no programmatic API.

Installs mocha-web with required peer deps, runs a basic Mocha test in Chromium via CLI.

// 1. Install dependencies npm install --save-dev mocha-web mocha @playwright/browser-chromium esbuild // 2. Create a test file test/example.spec.js const assert = require('assert'); describe('Example', () => { it('should pass', () => { assert.strictEqual(1 + 1, 2); }); }); // 3. Run tests in Chromium npx mocha-web "test/**/*.spec.js" -t 5000
mocha-web --version
Debug
Known issues
breakingNode.js version 18 is no longer supported; require Node >=20
fix
Upgrade Node.js to v20 or higher.
affects: >=2.0.0
deprecatedThe --esbuild-config option works only with esbuild config files; inline config not supported.
fix
Use a separate esbuild config file if bundling options are needed.
affects: >=2.0.0
gotchaPackage does not expose a programmatic JavaScript API; only a CLI binary.
fix
Use shell commands or child_process to invoke mocha-web programmatically.
affects: >=1.0.0
gotchaPeer dependencies (mocha, esbuild, @playwright/browser-chromium) must be installed manually; mocha-web does not install them automatically.
fix
Run npm install --save-dev mocha esbuild @playwright/browser-chromium alongside mocha-web.
affects: >=1.0.0
gotchaESM support in esbuild config requires format=esm, else default is CJS.
fix
Set format: 'esm' in your esbuild config file if you want ESM output.
affects: >=2.4.0
breakingRemoved deprecated 'devtools' launch option; use 'open-devtools' instead.
fix
Replace '--devtools' with '--open-devtools' in CLI arguments.
affects: >=2.6.1
Errors
Common errors & fixes
Error: Cannot find module 'mocha'
Missing peer dependency mocha.
fix
npm install --save-dev mocha
Error: Cannot find module 'esbuild'
Missing peer dependency esbuild.
fix
npm install --save-dev esbuild
Error: Cannot find module '@playwright/browser-chromium'
Missing peer dependency @playwright/browser-chromium.
fix
npm install --save-dev @playwright/browser-chromium
Error: The 'devtools' option is deprecated. Use 'open-devtools' instead.
Using deprecated --devtools flag.
fix
Use --open-devtools instead of --devtools.
Upgrade
Version history
2.6.1latest on npm
Audit
Dependencies
mocharequiredpeer dependency: test framework
@playwright/browser-chromiumrequiredpeer dependency: browser runtime
esbuildrequiredpeer dependency: bundling test files
Agent activity
2 hits · last 30 days
node
2
Resources