Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Aug 13, 2021
1 parent 6b3ddd3 commit 13d8bda
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
23 changes: 14 additions & 9 deletions docs/index.md
Expand Up @@ -876,7 +876,7 @@ Use this option to have Mocha check for global variables that are leaked while r
### `--dry-run`

> _New in v9.0.0._ Report tests without executing any of them, neither tests nor hooks.
> _New in v9.0.0_ Report tests without executing any of them, neither tests nor hooks.
### `--exit`

Expand All @@ -899,6 +899,10 @@ To ensure your tests aren't leaving messes around, here are some ideas to get st
- Try something like [wtfnode][npm-wtfnode]
- Use [`.only`](#exclusive-tests) until you find the test that causes Mocha to hang

### `--fail-zero`

> _New in v9.1.0_ Fail test run if no tests are encountered with `exit-code: 1`.
### `--forbid-only`

Enforce a rule that tests may not be exclusive (use of e.g., `describe.only()` or `it.only()` is disallowed).
Expand Down Expand Up @@ -1007,15 +1011,15 @@ Can be specified as a comma-delimited list.

### `--config <path>`

> _New in v6.0.0._
> _New in v6.0.0_
Specify an explicit path to a [configuration file](#configuring-mocha-nodejs).

By default, Mocha will search for a config file if `--config` is not specified; use `--no-config` to suppress this behavior.

### `--node-option <name>, -n <name>`

> _New in v9.1.0._
> _New in v9.1.0_
For Node.js and V8 options. Mocha forwards these options to Node.js by spawning a new child-process.<br>
The options are set without leading dashes `--`, e.g. `-n require=foo -n unhandled-rejections=strict`
Expand All @@ -1028,7 +1032,7 @@ Can also be specified as a comma-delimited list: `-n require=foo,unhandled-rejec
### `--package <path>`

> _New in v6.0.0._
> _New in v6.0.0_
Specify an explicit path to a [`package.json` file](#configuring-mocha-nodejs) (ostensibly containing configuration in a `mocha` property).

Expand All @@ -1042,7 +1046,7 @@ Specifying `--extension` will _remove_ `.js` as a test file extension; use `--ex

The option can be given multiple times. The option accepts a comma-delimited list: `--extension a,b` is equivalent to `--extension a --extension b`.

> _New in v8.2.0._
> _New in v8.2.0_
`--extension` now supports multipart extensions (e.g., `spec.js`), leading dots (`.js`) and combinations thereof (`.spec.js`);

Expand Down Expand Up @@ -1214,7 +1218,7 @@ These flags vary depending on your version of Node.js.

`node` flags can be defined in Mocha's [configuration](#configuring-mocha-nodejs).

> _New in v9.1.0._ You can also pass `node` flags to Node.js using [`--node-option`](#-node-option-name-n-name).
> _New in v9.1.0_ You can also pass `node` flags to Node.js using [`--node-option`](#-node-option-name-n-name).
### `--enable-source-maps`

Expand All @@ -1235,7 +1239,7 @@ Prepend `--v8-` to any flag listed in the output of `node --v8-options` (excludi

V8 flags can be defined in Mocha's [configuration](#configuring-mocha-nodejs).

> _New in v9.1.0._ You can also pass V8 flags (without `--v8-`) to Node.js using [`--node-option`](#-node-option-name-n-name).
> _New in v9.1.0_ You can also pass V8 flags (without `--v8-`) to Node.js using [`--node-option`](#-node-option-name-n-name).
## Parallel Tests

Expand Down Expand Up @@ -1366,7 +1370,7 @@ It's unlikely (but not impossible) to see a performance gain from a [job count](

## Root Hook Plugins

> _New in v8.0.0._
> _New in v8.0.0_
In some cases, you may want a [hook](#hooks) before (or after) every test in every file. These are called _root hooks_. Previous to v8.0.0, the way to accomplish this was to use `--file` combined with root hooks (see [example above](#root-hooks-are-not-global)). This still works in v8.0.0, but _not_ when running tests in parallel mode! For that reason, running root hooks using this method is _strongly discouraged_, and may be deprecated in the future.

Expand Down Expand Up @@ -1590,7 +1594,7 @@ If you're a library maintainer, and your library uses root hooks, you can migrat

## Global Fixtures

> New in v8.2.0
> _New in v8.2.0_
At first glance, _global fixtures_ seem similar to [root hooks](#root-hook-plugins). However, unlike root hooks, global fixtures:

Expand Down Expand Up @@ -2118,6 +2122,7 @@ mocha.setup({
bail: true,
checkLeaks: true,
dryRun: true,
failZero: true,
forbidOnly: true,
forbidPending: true,
global: ['MyLib'],
Expand Down
1 change: 1 addition & 0 deletions example/config/.mocharc.js
Expand Up @@ -14,6 +14,7 @@ module.exports = {
diff: true,
exit: false, // could be expressed as "'no-exit': true"
extension: ['js', 'cjs', 'mjs'],
'fail-zero': true,
fgrep: 'something', // fgrep and grep are mutually exclusive
file: ['/path/to/some/file', '/path/to/some/other/file'],
'forbid-only': false,
Expand Down
1 change: 1 addition & 0 deletions example/config/.mocharc.yml
Expand Up @@ -8,6 +8,7 @@ delay: false
diff: true
exit: false # could be expressed as "no-exit: true"
extension: ['js', 'cjs', 'mjs']
fail-zero: true
# fgrep and grep are mutually exclusive
fgrep: 'something'
file:
Expand Down

0 comments on commit 13d8bda

Please sign in to comment.