Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

fix broken docs

Christopher Hiller9b7a28202c28
diff --git a/docs/index.md b/docs/index.md
index 10c05297..eb53813f 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -815,85 +815,87 @@ Mocha supports the `err.expected` and `err.actual` properties of any thrown `Ass
<!-- AUTO-GENERATED-CONTENT:START (usage:executable=bin/mocha) -->
```plain
+
mocha [spec..]
Run tests with Mocha
Commands
-mocha debug [spec..] Run tests with Mocha [default]
-mocha init <path> create a client-side Mocha setup at <path>
+ mocha debug [spec..] Run tests with Mocha [default]
+ mocha init <path> create a client-side Mocha setup at <path>
Rules & Behavior
---allow-uncaught Allow uncaught errors to propagate [boolean]
---async-only, -A Require all tests to use a callback (async) or
-return a Promise [boolean]
---bail, -b Abort ("bail") after first test failure [boolean]
---check-leaks Check for global variable leaks [boolean]
---delay Delay initial execution of root suite
---exit Force Mocha to quit after tests complete [boolean]
---forbid-only Fail if exclusive test(s) encountered [boolean]
---forbid-pending Fail if pending test(s) encountered [boolean]
---global, --globals List of allowed global variables [array]
---retries Retry failed tests this many times [number]
---slow, -s Specify "slow" test threshold (in milliseconds)
-[number] [default: 75]
---timeout, -t, --timeouts Specify test timeout threshold (in milliseconds)
-[number] [default: 2000]
---ui, -u Specify user interface [string] [default: "bdd"]
+ --allow-uncaught Allow uncaught errors to propagate [boolean]
+ --async-only, -A Require all tests to use a callback (async) or
+ return a Promise [boolean]
+ --bail, -b Abort ("bail") after first test failure [boolean]
+ --check-leaks Check for global variable leaks [boolean]
+ --delay Delay initial execution of root suite
+ --exit Force Mocha to quit after tests complete [boolean]
+ --forbid-only Fail if exclusive test(s) encountered [boolean]
+ --forbid-pending Fail if pending test(s) encountered [boolean]
+ --global, --globals List of allowed global variables [array]
+ --retries Retry failed tests this many times [number]
+ --slow, -s Specify "slow" test threshold (in milliseconds)
+ [number] [default: 75]
+ --timeout, -t, --timeouts Specify test timeout threshold (in milliseconds)
+ [number] [default: 2000]
+ --ui, -u Specify user interface [string] [default: "bdd"]
Reporting & Output
---color, -c, --colors Force-enable color output [boolean]
---diff Show diff on failure
-[boolean] [default: true]
---full-trace Display full stack traces [boolean]
---growl, -G Enable Growl notifications [boolean]
---inline-diffs Display actual/expected differences
-inline within each string [boolean]
---reporter, -R Specify reporter to use
-[string] [default: "spec"]
---reporter-option, --reporter-options, Reporter-specific options
--O (<k=v,[k1=v1,..]>) [array]
+ --color, -c, --colors Force-enable color output [boolean]
+ --diff Show diff on failure
+ [boolean] [default: true]
+ --full-trace Display full stack traces [boolean]
+ --growl, -G Enable Growl notifications [boolean]
+ --inline-diffs Display actual/expected differences
+ inline within each string [boolean]
+ --reporter, -R Specify reporter to use
+ [string] [default: "spec"]
+ --reporter-option, --reporter-options, Reporter-specific options
+ -O (<k=v,[k1=v1,..]>) [array]
Configuration
---config Path to config file [default: (nearest rc file)]
---opts Path to `mocha.opts` [string] [default: "./test/mocha.opts"]
---package Path to package.json for config [string]
+ --config Path to config file [default: (nearest rc file)]
+ --opts Path to `mocha.opts` [string] [default: "./test/mocha.opts"]
+ --package Path to package.json for config [string]
File Handling
---exclude Ignore file(s) or glob pattern(s)
-[array] [default: (none)]
---extension, --watch-extensions File extension(s) to load and/or watch
-[array] [default: js]
---file Specify file(s) to be loaded prior to root
-suite execution [array] [default: (none)]
---recursive Look for tests in subdirectories [boolean]
---require, -r Require module [array] [default: (none)]
---sort, -S Sort test files
---watch, -w Watch files in the current working directory
-for changes [boolean]
+ --exclude Ignore file(s) or glob pattern(s)
+ [array] [default: (none)]
+ --extension, --watch-extensions File extension(s) to load and/or watch
+ [array] [default: js]
+ --file Specify file(s) to be loaded prior to root
+ suite execution [array] [default: (none)]
+ --recursive Look for tests in subdirectories [boolean]
+ --require, -r Require module [array] [default: (none)]
+ --sort, -S Sort test files
+ --watch, -w Watch files in the current working directory
+ for changes [boolean]
Test Filters
---fgrep, -f Only run tests containing this string [string]
---grep, -g Only run tests matching this string or regexp [string]
---invert, -i Inverts --grep and --fgrep matches [boolean]
+ --fgrep, -f Only run tests containing this string [string]
+ --grep, -g Only run tests matching this string or regexp [string]
+ --invert, -i Inverts --grep and --fgrep matches [boolean]
Positional Arguments
-spec One or more files, directories, or globs to test
-[array] [default: ["test/"]]
+ spec One or more files, directories, or globs to test
+ [array] [default: ["test/"]]
Other Options
---help, -h Show usage information & exit [boolean]
---version, -V Show version number & exit [boolean]
---interfaces List built-in user interfaces & exit
---reporters List built-in reporters & exit
+ --help, -h Show usage information & exit [boolean]
+ --version, -V Show version number & exit [boolean]
+ --interfaces List built-in user interfaces & exit
+ --reporters List built-in reporters & exit
Mocha Resources
-Chat: https://gitter.im/mochajs/mocha/
-GitHub: https://github.com/mochajs/mocha.git
-Docs: https://mochajs.org/
+ Chat: https://gitter.im/mochajs/mocha
+ GitHub: https://github.com/mochajs/mocha.git
+ Docs: https://mochajs.org/
+
```
-<!-- usagestop -->
+<!-- AUTO-GENERATED-CONTENT:END -->
### `--allow-uncaught`
diff --git a/package-lock.json b/package-lock.json
index 0a1503a5..1f9fc634 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1586,6 +1586,15 @@
"supports-color": "^2.0.0"
},
"dependencies": {
+ "strip-ansi": {
+ "version": "3.0.1",
+ "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
+ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "^2.0.0"
+ }
+ },
"supports-color": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
@@ -1757,6 +1766,17 @@
"string-width": "^1.0.1",
"strip-ansi": "^3.0.1",
"wrap-ansi": "^2.0.0"
+ },
+ "dependencies": {
+ "strip-ansi": {
+ "version": "3.0.1",
+ "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
+ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "^2.0.0"
+ }
+ }
}
},
"clone": {
@@ -5311,6 +5331,18 @@
"string-width": "^1.0.1",
"strip-ansi": "^3.0.1",
"wide-align": "^1.1.0"
+ },
+ "dependencies": {
+ "strip-ansi": {
+ "version": "3.0.1",
+ "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
+ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "ansi-regex": "^2.0.0"
+ }
+ }
}
},
"get-caller-file": {
@@ -8279,6 +8311,15 @@
"requires": {
"chalk": "^1.0.0"
}
+ },
+ "strip-ansi": {
+ "version": "3.0.1",
+ "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
+ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "^2.0.0"
+ }
}
}
},
@@ -16472,6 +16513,16 @@
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
"strip-ansi": "^3.0.0"
+ },
+ "dependencies": {
+ "strip-ansi": {
+ "version": "3.0.1",
+ "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
+ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
+ "requires": {
+ "ansi-regex": "^2.0.0"
+ }
+ }
}
},
"string.prototype.repeat": {
@@ -16507,11 +16558,20 @@
"dev": true
},
"strip-ansi": {
- "version": "3.0.1",
- "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
- "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.0.0.tgz",
+ "integrity": "sha512-Uu7gQyZI7J7gn5qLn1Np3G9vcYGTVqB+lFTytnDJv83dd8T22aGH451P3jueT2/QemInJDfxHB5Tde5OzgG1Ow==",
+ "dev": true,
"requires": {
- "ansi-regex": "^2.0.0"
+ "ansi-regex": "^4.0.0"
+ },
+ "dependencies": {
+ "ansi-regex": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.0.0.tgz",
+ "integrity": "sha512-iB5Dda8t/UqpPI/IjsejXu5jOGDrzn41wJyljwPH65VCIbk6+1BzFIMJGFwTNrYXT1CrD+B4l19U7awiQ8rk7w==",
+ "dev": true
+ }
}
},
"strip-bom": {
@@ -17975,6 +18035,16 @@
"requires": {
"string-width": "^1.0.1",
"strip-ansi": "^3.0.1"
+ },
+ "dependencies": {
+ "strip-ansi": {
+ "version": "3.0.1",
+ "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
+ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
+ "requires": {
+ "ansi-regex": "^2.0.0"
+ }
+ }
}
},
"wrap-fn": {
diff --git a/package.json b/package.json
index 5df34a2c..7e5e9153 100644
--- a/package.json
+++ b/package.json
@@ -529,6 +529,7 @@
"rewiremock": "^3.12.3",
"rimraf": "^2.5.2",
"sinon": "^7.1.1",
+ "strip-ansi": "^5.0.0",
"svgo": "^0.7.2",
"through2": "^2.0.5",
"unexpected": "^10.39.2",
diff --git a/scripts/markdown-magic.config.js b/scripts/markdown-magic.config.js
index d5326174..5965c572 100644
--- a/scripts/markdown-magic.config.js
+++ b/scripts/markdown-magic.config.js
@@ -8,6 +8,7 @@
*/
const {execSync} = require('child_process');
+const stripAnsi = require('strip-ansi');
const markdownToc = require('markdown-toc');
const path = require('path');
@@ -17,11 +18,13 @@ exports.transforms = {
const flag = options.flag || '--help';
const header = options.header || '\n```plain';
const footer = options.footer || '```\n';
- const output = String(
- execSync(`${process.execPath} ${executable} ${flag} -C`, {
- cwd: path.join(__dirname, '..')
- })
- ).trim();
+ const output = stripAnsi(
+ String(
+ execSync(`${process.execPath} ${executable} ${flag}`, {
+ cwd: path.join(__dirname, '..')
+ })
+ ).trim()
+ );
return [header, output, footer].join('\n\n');
},
// we can't use the builtin `TOC` plugin in markdown-magic