Contains CLI entry point and public API for programmatic usage in Node.js.
- Source:
Methods
(static) loadOptions(argvopt) → {external:yargsParser.Arguments}
Parses options read from .mocharc.*
and package.json
.
- Source:
Priority list:
- Command-line args
MOCHA_OPTIONS
environment variable.- RC file (
.mocharc.c?js
,.mocharc.ya?ml
,mocharc.json
) mocha
prop ofpackage.json
- default configuration (
lib/mocharc.json
)
If a "one-and-done" option is present in the argv
array, no external config files will be read.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
argv | string | Array:.<string:> | <optional> | Arguments to parse |
Returns:
Parsed args from everything
(static) loadPkgRc(argsopt) → {external:yargsParser.Arguments|void}
- Source:
Given path to package.json
in args.package
, attempt to load config from mocha
prop.
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
args | Object | <optional> | Arguments object Properties
|
Returns:
Parsed config, or nothing if args.package
is false
- Type
- external:yargsParser.Arguments | void
(static) loadRc(argsopt) → {external:yargsParser.Arguments|void}
- Source:
Given path to config file in args.config
, attempt to load & parse config file.
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
args | Object | <optional> | Arguments object Properties
|
Returns:
Parsed config, or nothing if args.config
is false
- Type
- external:yargsParser.Arguments | void
(static) lookupFiles(filepath, extensionsopt, recursiveopt) → {Array:.<string:>}
- Source:
Filenames are returned in traversal order by the OS/filesystem.
Make no assumption that the names will be sorted in any fashion.
Parameters:
Throws:
if no files match pattern.
- Type
- Error
if
filepath
is directory andextensions
not provided.- Type
- TypeError
Returns:
An array of paths.
(static) main(argv, mochaArgsopt)
Mocha's main command-line entry-point.
- Source:
- Accepts an
Array
of arguments - Modifies Node.js' search path for easy loading of consumer modules
- Sets Error.stackTraceLimit to
Infinity