From 13d8bda01e4cd69b4b659af3e7bb3068f7fdb0db Mon Sep 17 00:00:00 2001 From: juergba Date: Thu, 12 Aug 2021 16:47:34 +0200 Subject: [PATCH] docs --- docs/index.md | 23 ++++++++++++++--------- example/config/.mocharc.js | 1 + example/config/.mocharc.yml | 1 + 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/docs/index.md b/docs/index.md index 1c26cea1d0..8cd94041f2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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` @@ -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). @@ -1007,7 +1011,7 @@ Can be specified as a comma-delimited list. ### `--config ` -> _New in v6.0.0._ +> _New in v6.0.0_ Specify an explicit path to a [configuration file](#configuring-mocha-nodejs). @@ -1015,7 +1019,7 @@ By default, Mocha will search for a config file if `--config` is not specified; ### `--node-option , -n ` -> _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.
The options are set without leading dashes `--`, e.g. `-n require=foo -n unhandled-rejections=strict` @@ -1028,7 +1032,7 @@ Can also be specified as a comma-delimited list: `-n require=foo,unhandled-rejec ### `--package ` -> _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). @@ -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`); @@ -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` @@ -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 @@ -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. @@ -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: @@ -2118,6 +2122,7 @@ mocha.setup({ bail: true, checkLeaks: true, dryRun: true, + failZero: true, forbidOnly: true, forbidPending: true, global: ['MyLib'], diff --git a/example/config/.mocharc.js b/example/config/.mocharc.js index e80004a9dc..d2203fc296 100644 --- a/example/config/.mocharc.js +++ b/example/config/.mocharc.js @@ -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, diff --git a/example/config/.mocharc.yml b/example/config/.mocharc.yml index c1e13a5d35..456b351332 100644 --- a/example/config/.mocharc.yml +++ b/example/config/.mocharc.yml @@ -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: