diff --git a/docs/index.md b/docs/index.md index 12b4b18955..87e591fd97 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1015,6 +1015,15 @@ 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 , -n ` + +> _New in v9.1.0._ + +For Node.js and V8 options. Mocha forwards these options to Node.js by spawning a new child-process.
+e.g. `-n require=foo -n unhandled-rejections=strict` + +Can also be specified as a comma-delimited list: `-n "require=foo, unhandled-rejections=strict"` + ### `--opts ` > _Removed in v8.0.0. Please use [configuration file](#configuring-mocha-nodejs) instead._ @@ -1159,8 +1168,6 @@ Requires either `--grep` or `--fgrep` (but not both). ### `--inspect, --inspect-brk, inspect` -> _BREAKING CHANGE in v7.0.0; `--debug` / `--debug-brk` are removed and `debug` is deprecated._ - Enables Node.js' inspector. Use `--inspect` / `--inspect-brk` to launch the V8 inspector for use with Chrome Dev Tools. @@ -1209,6 +1216,10 @@ 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). + ### `--enable-source-maps` > _New in Node.js v12.12.0_ @@ -1228,6 +1239,10 @@ 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). + ## Parallel Tests > _New in v.8.0.0._ diff --git a/example/config/.mocharc.js b/example/config/.mocharc.js index 235f6e0b86..bdd89e769f 100644 --- a/example/config/.mocharc.js +++ b/example/config/.mocharc.js @@ -26,6 +26,7 @@ module.exports = { 'inline-diffs': false, // invert: false, // needs to be used with grep or fgrep jobs: 1, + 'node-option': ['unhandled-rejections=strict'], // without leading "--", also V8 flags package: './package.json', parallel: false, recursive: false, diff --git a/example/config/.mocharc.yml b/example/config/.mocharc.yml index 0172f7cd40..4ba30dff22 100644 --- a/example/config/.mocharc.yml +++ b/example/config/.mocharc.yml @@ -29,6 +29,8 @@ inline-diffs: false # needs to be used with grep or fgrep # invert: false jobs: 1 +node-option: + - 'unhandled-rejections=strict' # without leading "--", also V8 flags package: './package.json' parallel: false recursive: false