Registry / testing / kocha
library1.9.1jsnpmunverified

Kocha (v1.9.1) is a modern, simpler clone of Mocha for JavaScript testing in Node.js. It supports BDD-style test syntax (describe/it/beforeEach/afterEach) without globals, making it lint-friendly. It requires explicit imports from the 'kocha' package. Kocha has no dependencies and uses CommonJS modules. It offers timeout and retries as explicit API calls rather than via 'this'. It is maintained with release cadence as needed. Key differentiators: no globals, no standalone browser mode, no TDD/QUnit interfaces, intentionally simpler than Mocha.

npm install kocha
INSTALL
IMPORT
SIG · KOCHA
K
kocha
testingjavascriptv1.9.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.

describe
const { describe } = require('kocha')
const describe = require('kocha').describe;
CommonJS destructuring import is standard; use require('kocha') to get all exports.
it
const { it } = require('kocha')
const it = require('kocha').it;
Same as describe, destructure from require call.
beforeEach
const { beforeEach } = require('kocha')
const beforeEach = require('kocha').beforeEach;
Hook functions are exported individually.
timeout
const { timeout } = require('kocha')
timeout = require('kocha').timeout;
Exported as a function, not attached to 'this' like in Mocha.

Shows basic BDD test suite with hooks, assertions, and skip using Kocha.

const { describe, it, before, after, beforeEach, afterEach, timeout, retries } = require('kocha') const assert = require('assert') let value beforeEach(() => { value = 42 }) describe('example', () => { it('should return 42', () => { assert.strictEqual(value, 42) }) it.skip('pending test', () => { // skipped }) }) // run with: ./node_modules/.bin/kocha test.js
kocha --version
Debug
Known issues
breakingKocha does not support this.timeout(ms) or this.retries(n); use the exported timeout() and retries() functions instead.
fix
Call timeout(n) and retries(n) directly from require('kocha') at the suite level.
affects: >=0.0.0
breakingKocha does not support xdescribe, xit, context, or specify; use describe.skip, it.skip, describe, it respectively.
fix
Replace xdescribe with describe.skip, xit with it.skip, context with describe, specify with it.
affects: >=0.0.0
gotchaKocha is not a drop-in replacement for Mocha; it lacks TDD, QUnit, and standalone browser mode. Requires explicit imports of describe, it, etc.
fix
Imports must be added to each test file; tests expecting global Mocha functions will fail.
affects: >=0.0.0
gotchaThe command-line interface is 'kocha', not 'mocha'. Ensure node_modules/.bin/kocha is used to run tests.
fix
Run tests using './node_modules/.bin/kocha test.js' or add a script in package.json: 'scripts': { 'test': 'kocha test.js' }.
affects: >=0.0.0
Errors
Common errors & fixes
ReferenceError: describe is not defined
Using Mocha globals without importing Kocha's exports.
fix
Add 'const { describe, it } = require('kocha')' at the top of your test file.
TypeError: describe.skip is not a function
Attempting to use xdescribe (undefined) instead of describe.skip.
fix
Replace xdescribe with describe.skip.
Error: timeout is not a function
Calling this.timeout inside a test callback; Kocha does not support that.
fix
Call timeout(n) directly from require('kocha') at suite level.
Cannot find module 'kocha'
Kocha is not installed in node_modules.
fix
Run 'npm install kocha --save-dev' in your project directory.
Upgrade
Version history
1.9.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
kocha — npm install kocha · libregistry