Skip to content

Instantly share code, notes, and snippets.

@boneskull
Last active November 7, 2018 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boneskull/1babfa5c0d3c70c2826488ea5f066772 to your computer and use it in GitHub Desktop.
Save boneskull/1babfa5c0d3c70c2826488ea5f066772 to your computer and use it in GitHub Desktop.
mocha w/ yargs help output (new.txt) vs old output (old.txt)
mocha [spec..]
Run tests with Mocha
Commands:
mocha [spec..] Run tests with Mocha [default]
mocha init <path> create a client-side Mocha setup at <path>
Rules & Behavior
--allow-uncaught Allow uncaught errors to propagate [boolean]
--async-only, -A Require all tests to use a callback (async) or return a
Promise [boolean]
--check-leaks Check for global variable leaks [boolean]
--forbid-only Fail if exclusive test(s) encountered [boolean]
--forbid-pending Fail if pending test(s) encountered [boolean]
--no-timeouts Disable timeouts [boolean]
--bail, -b Abort ("bail") after first test failure [boolean]
--delay Delay initial execution of root suite [boolean]
--exit Force Mocha to quit after tests complete [boolean]
--globals Comma-separated list of allowed global variables [string]
--retries Retry failed tests this many times [number] [default: 0]
--slow, -s Specify "slow" test threshold (in milliseconds)
[number] [default: 75]
--timeout, -t Specify test timeout threshold (in milliseconds)
[default: 2000]
--ui, -u Specify user interface [string] [default: "bdd"]
Reporting & Output
--full-trace Display full stack traces [boolean]
--inline-diffs Display actual/expected differences inline within each
string [boolean]
--no-colors, -C Disable color output [boolean]
--reporter-options, -O Reporter-specific options (<k=v,[k1=v1,..]>) [string]
--colors, -c Force-enable color output [boolean]
--diff Show diff on failure [boolean] [default: true]
--growl, -G Enable Growl notifications [boolean]
--reporter, -R Specify reporter to use [string] [default: "spec"]
File Handling
--watch-extensions Comma-separated list of extensions to monitor with
"--watch" [string] [default: "js"]
--compilers Use the given module(s) to compile files
(<ext:module,[ext1:module1]>) [string]
--exclude Ignore file(s) or glob pattern(s)[array] [default: (none)]
--file Specify file(s) to be loaded prior to root suite execution
[array] [default: (none)]
--recursive Look for tests in subdirectories [boolean]
--require, -r Require module [array] [default: (none)]
--sort, -S Sort test files [boolean]
--watch, -w Watch files in the current working directory for changes
[boolean]
Config Files
--config Load config file [default: (nearest rc file)]
--opts Path to `mocha.opts` [string] [default: "./test/mocha.opts"]
Test Filters
--fgrep, -f Only run tests containing this string [string]
--grep, -g Only run tests matching this string or regexp [string]
--invert, -i Inverts --grep and --fgrep matches [boolean]
Positional Arguments
spec One or more files, directories, or globs to test [default: ["test/"]]
Other Options
--help, -h Show help [boolean]
--version Show version number [boolean]
--show-node-options Show supported Node.js & V8 options; use with "--help"
[boolean]
--interfaces List built-in user interfaces & exit [boolean]
--reporters List built-in reporters & exit [boolean]
Read the docs at https://mochajs.org
Usage: mocha [debug] [options] [files]
Options:
-V, --version output the version number
-A, --async-only force all tests to take a callback (async) or return a promise
-c, --colors force enabling of colors
-C, --no-colors force disabling of colors
-G, --growl enable growl notification support
-O, --reporter-options <k=v,k2=v2,...> reporter-specific options
-R, --reporter <name> specify the reporter to use (default: spec)
-S, --sort sort test files
-b, --bail bail after first test failure
-d, --debug enable node's debugger, synonym for node --debug
-g, --grep <pattern> only run tests matching <pattern>
-f, --fgrep <string> only run tests containing <string>
-gc, --expose-gc expose gc extension
-i, --invert inverts --grep and --fgrep matches
-r, --require <name> require the given module
-s, --slow <ms> "slow" test threshold in milliseconds [75]
-t, --timeout <ms> set test-case timeout in milliseconds [2000]
-u, --ui <name> specify user-interface (bdd|tdd|qunit|exports) (default: bdd)
-w, --watch watch files for changes
--check-leaks check for global variable leaks
--full-trace display the full stack trace
--compilers <ext>:<module>,... use the given module(s) to compile files (default: )
--debug-brk enable node's debugger breaking on the first line
--globals <names> allow the given comma-delimited global [names] (default: )
--es_staging enable all staged features
--harmony<_classes,_generators,...> all node --harmony* flags are available
--preserve-symlinks Instructs the module loader to preserve symbolic links when resolving and caching modules
--icu-data-dir include ICU data
--inline-diffs display actual/expected differences inline within each string
--no-diff do not show a diff on failure
--inspect activate devtools in chrome
--inspect-brk activate devtools in chrome and break on the first line
--interfaces display available interfaces
--no-deprecation silence deprecation warnings
--exit force shutdown of the event loop after test run: mocha will call process.exit
--no-timeouts disables timeouts, given implicitly with --debug
--no-warnings silence all node process warnings
--opts <path> specify opts path (default: test/mocha.opts)
--perf-basic-prof enable perf linux profiler (basic support)
--napi-modules enable experimental NAPI modules
--prof log statistical profiling information
--log-timer-events Time events including external callbacks
--recursive include sub directories
--reporters display available reporters
--retries <times> set numbers of time to retry a failed test case
--throw-deprecation throw an exception anytime a deprecated function is used
--trace trace function calls
--trace-deprecation show stack traces on deprecations
--trace-warnings show stack traces on node process warnings
--use_strict enforce strict mode
--watch-extensions <ext>,... additional extensions to monitor with --watch (default: js)
--delay wait for async suite definition
--allow-uncaught enable uncaught errors to propagate
--forbid-only causes test marked with only to fail the suite
--forbid-pending causes pending tests and test marked with skip to fail the suite
--file <file> include a file to be ran during the suite (default: )
--exclude <file> a file or glob pattern to ignore (default: )
-h, --help output usage information
Commands:
init <path> initialize a client-side mocha setup at <path>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment