Scroll to navigation

MOCHA(1) User Commands MOCHA(1)

NAME

mocha - simple, flexible, fun test framework

SYNOPSIS

mocha [spec..]

DESCRIPTION

mocha init <path>

Commands:

create a client-side Mocha setup at <path>

OPTIONS

File extension(s) to load
Specify file(s) to be loaded prior to root suite execution
List of allowed global variables
Ignore file(s) or glob pattern(s)
Node or V8 option (no leading "--")

--reporter-option, --reporter-options, -O Reporter-specific options (<k=v,[k1=v1,..]>)

Require module
List of paths or globs to watch
List of paths or globs to exclude from watching
Allow uncaught errors to propagate
Require all tests to use a callback (async) or return a Promise
Abort ("bail") after first test failure
Check for global variable leaks
Force-enable color output
Delay initial execution of root suite
Show diff on failure
Report tests without executing them
Force Mocha to quit after tests complete
Report tests as failed when affected by hook failures (before/beforeEach)
Not fail test run if tests were failed
Fail test run if no test(s) encountered
Fail if exclusive test(s) encountered
Fail if pending test(s) encountered
Display full stack traces
Display actual/expected differences inline within each string
Inverts --grep and --fgrep matches
List built-in user interfaces & exit
List built-in reporters & exit
Force-disable color output
Run tests in parallel
Use POSIX and UNIX shell exit codes as Mocha's return value
Look for tests in subdirectories
Sort test files
Watch files in the current working directory for changes
Retry failed tests this many times
Number of concurrent jobs for --parallel; use 1 to run in serial
Path to config file
Only run tests containing this string
Only run tests matching this string or regexp
Path to package.json for config
Specify reporter to use
Specify user interface
Specify "slow" test threshold (in milliseconds)
Specify test timeout threshold (in milliseconds)
Show usage information & exit
Show version number & exit

Mocha Resources

Chat: https://discord.gg/KeDn2uXhER
GitHub: https://github.com/mochajs/mocha.git
Docs: https://mochajs.org/
October 2026 mocha 12.0.3