{"id":25952,"library":"mocha-web","title":"mocha-web","description":"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.","status":"active","version":"2.6.1","language":"javascript","source_language":"en","source_url":"https://github.com/dazl-dev/mocha-web","tags":["javascript","typescript"],"install":[{"cmd":"npm install mocha-web","lang":"bash","label":"npm"},{"cmd":"yarn add mocha-web","lang":"bash","label":"yarn"},{"cmd":"pnpm add mocha-web","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: test framework","package":"mocha","optional":false},{"reason":"peer dependency: browser runtime","package":"@playwright/browser-chromium","optional":false},{"reason":"peer dependency: bundling test files","package":"esbuild","optional":false}],"imports":[{"note":"CLI usage; no programmatic API exported.","wrong":"mocha-web","symbol":"default (CLI)","correct":"npx mocha-web \"test/**/*.spec.js\""},{"note":"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.","wrong":"const mochaWeb = require('mocha-web')","symbol":"default export","correct":"import mochaWeb from 'mocha-web'"},{"note":"Run as a command-line tool; no programmatic API.","wrong":"","symbol":"mocha-web cli","correct":"mocha-web --version"}],"quickstart":{"code":"// 1. Install dependencies\nnpm install --save-dev mocha-web mocha @playwright/browser-chromium esbuild\n\n// 2. Create a test file test/example.spec.js\nconst assert = require('assert');\ndescribe('Example', () => {\n  it('should pass', () => {\n    assert.strictEqual(1 + 1, 2);\n  });\n});\n\n// 3. Run tests in Chromium\nnpx mocha-web \"test/**/*.spec.js\" -t 5000","lang":"javascript","description":"Installs mocha-web with required peer deps, runs a basic Mocha test in Chromium via CLI."},"warnings":[{"fix":"Upgrade Node.js to v20 or higher.","message":"Node.js version 18 is no longer supported; require Node >=20","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use a separate esbuild config file if bundling options are needed.","message":"The --esbuild-config option works only with esbuild config files; inline config not supported.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Use shell commands or child_process to invoke mocha-web programmatically.","message":"Package does not expose a programmatic JavaScript API; only a CLI binary.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Run npm install --save-dev mocha esbuild @playwright/browser-chromium alongside mocha-web.","message":"Peer dependencies (mocha, esbuild, @playwright/browser-chromium) must be installed manually; mocha-web does not install them automatically.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set format: 'esm' in your esbuild config file if you want ESM output.","message":"ESM support in esbuild config requires format=esm, else default is CJS.","severity":"gotcha","affected_versions":">=2.4.0"},{"fix":"Replace '--devtools' with '--open-devtools' in CLI arguments.","message":"Removed deprecated 'devtools' launch option; use 'open-devtools' instead.","severity":"breaking","affected_versions":">=2.6.1"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"npm install --save-dev mocha","cause":"Missing peer dependency mocha.","error":"Error: Cannot find module 'mocha'"},{"fix":"npm install --save-dev esbuild","cause":"Missing peer dependency esbuild.","error":"Error: Cannot find module 'esbuild'"},{"fix":"npm install --save-dev @playwright/browser-chromium","cause":"Missing peer dependency @playwright/browser-chromium.","error":"Error: Cannot find module '@playwright/browser-chromium'"},{"fix":"Use --open-devtools instead of --devtools.","cause":"Using deprecated --devtools flag.","error":"Error: The 'devtools' option is deprecated. Use 'open-devtools' instead."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}