Scroll to navigation

MOCHA(1) User Commands MOCHA(1)

NAME

mocha - simple, flexible, fun test framework

DESCRIPTION

mocha [spec..]

Run tests with Mocha

Commands

Run tests with Mocha [default]
create a client-side Mocha setup at <path>

Rules & Behavior

Allow uncaught errors to propagate [boolean]
Require all tests to use a callback (async) or return a Promise [boolean]
Abort ("bail") after first test failure [boolean]
Check for global variable leaks [boolean]
Delay initial execution of root suite [boolean]
Report tests without executing them [boolean]
Force Mocha to quit after tests complete [boolean]
Fail test run if no test(s) encountered [boolean]
Fail if exclusive test(s) encountered [boolean]
Fail if pending test(s) encountered [boolean]
List of allowed global variables [array]
Number of concurrent jobs for --parallel; use 1 to run in serial
[number] [default: (number of CPU cores - 1)]
Run tests in parallel [boolean]
Retry failed tests this many times [number]
Specify "slow" test threshold (in milliseconds) [string] [default: 75]
Specify test timeout threshold (in milliseconds) [string] [default: 2000]
Specify user interface [string] [default: "bdd"]

Reporting & Output

Force-enable color output [boolean]
Show diff on failure [boolean] [default: true]
Display full stack traces [boolean]
Display actual/expected differences inline within each string [boolean]
Specify reporter to use [string] [default: "spec"]
Reporter-specific options
(<k=v,[k1=v1,..]>) [array]

Configuration

Path to config file [string] [default: (nearest rc file)]
Node or V8 option (no leading "--") [array]
Path to package.json for config [string]

File Handling

File extension(s) to load [array] [default: ["js","cjs","mjs"]]
Specify file(s) to be loaded prior to root suite execution [array] [default: (none)]
Ignore file(s) or glob pattern(s) [array] [default: (none)]
Look for tests in subdirectories [boolean]
Require module [array] [default: (none)]
Sort test files [boolean]
Watch files in the current working directory for changes [boolean]
List of paths or globs to watch [array]
List of paths or globs to exclude from watching [array] [default: ["node_modules",".git"]]

Test Filters

Only run tests containing this string [string]
Only run tests matching this string or regexp [string]
Inverts --grep and --fgrep matches [boolean]

Positional Arguments

One or more files, directories, or globs to test
[array] [default: ["test"]]

Other Options

Show usage information & exit [boolean]
Show version number & exit [boolean]
List built-in user interfaces & exit [boolean]
List built-in reporters & exit [boolean]

Mocha Resources

Chat: ?[35mhttps://gitter.im/mochajs/mocha?[39m
GitHub: ?[34mhttps://github.com/mochajs/mocha.git?[39m
Docs: ?[33mhttps://mochajs.org/?[39m
August 2023 mocha 10.2.0