Configures one or more global setup fixtures. If given no parameters, unsets any previously-set fixtures.
Configures one or more global teardown fixtures. If given no parameters, unsets any previously-set fixtures.
Add test file
.
Enable uncaught errors to propagate (in browser).
Makes all tests async (accepting a callback)
Enable or disable bailing on the first failure.
Enable global leak checking.
Enables or disables whether or not to dispose after each test run. Disable this to ensure you can run the test suite multiple times. If disabled, be sure to dispose mocha when you're done to prevent memory leaks.
Delay root suite execution.
Manually dispose this mocha instance. Mark this instance as disposed
and unable to run more tests.
It also removes function references to tests functions and hooks, so variables trapped in closures can be cleaned by the garbage collector.
Whether to activate dry-run mode.
Whether to activate dry-run mode. Defaults to true
.
Toggle execution of any global setup fixture(s)
Toggle execution of any global teardown fixture(s)
Escape string and add it to grep as a RegExp.
Tests marked only fail the suite
Pending tests and tests marked skip fail the suite
Display long stack-trace on failing
Ignore globals
array or string.
Enable growl support.
Returns true
if one or more global setup fixtures have been supplied
Returns true
if one or more global teardown fixtures have been supplied
Invert .grep()
matches.
Load registered files.
Loads ESM (and CJS) test files asynchronously.
Disable syntax highlighting (in browser).
Toggles parallel mode.
Must be run before calling run
. Changes the Runner
class to
use; also enables lazy file loading if not already done so.
Set reporter to one of the built-in reporters.
Set reporter to the provided constructor, one of the built-in reporters, or loads a reporter
from a module path. Defaults to "spec"
.
Set the number of times to retry failed tests.
Assigns hooks to the root suite.
Run tests and invoke fn()
when complete.
Note that run
relies on Node's require
to execute
the test interface functions and will be subject to the
cache - if the files are already in the require
cache,
they will effectively be skipped. Therefore, to run tests
multiple times or to run tests in files that are already
in the require
cache, make sure to clear them from the
cache first in whichever manner best suits your needs.
Set slowness threshold in milliseconds.
Set the timeout in milliseconds.
Set test UI to one of the built-in test interfaces.
Set test UI to one of the built-in test interfaces or loads a test interface from a module
path. Defaults to "bdd"
.
Unloads files
from Node's require
cache.
This allows required files to be "freshly" reloaded, providing the ability to reuse a Mocha instance programmatically. Note: does not clear ESM module files from the cache
Mocha API
https://mochajs.org/api/mocha