Skip to content

Commit fbceb19

Browse files
authored
docs: fix new website typos, improve readability (#5312)
* Fix typos, improve readability * Cleanup decision tree intro
1 parent b0c2696 commit fbceb19

17 files changed

+32
-32
lines changed

docs-next/src/content/docs/declaring/dynamic-tests.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Dynamic Tests
44
---
55

66
Given Mocha's use of function expressions to define suites and test cases, it's straightforward to generate your tests dynamically.
7-
No special syntax is required — plain old JavaScript can be used to achieve functionality similar to "parameterized" tests, which you may have seen in other frameworks.
7+
No special syntax is required--plain old JavaScript can be used to achieve functionality similar to "parameterized" tests, which you may have seen in other frameworks.
88

99
Take the following example:
1010

@@ -77,7 +77,7 @@ const tests = await new Promise((resolve) => {
7777
]);
7878
});
7979

80-
// in suites ASYNCHRONOUS callbacks are NOT supported
80+
// in suites, async callbacks are **not** supported
8181
describe("add()", function () {
8282
tests.forEach(({ args, expected }) => {
8383
it(`correctly adds ${args.length} args`, function () {

docs-next/src/content/docs/declaring/inclusive-tests.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Inclusive Tests
55

66
This feature is the inverse of `.only()`.
77
By appending `.skip()`, you may tell Mocha to ignore test case(s).
8-
Anything skipped will be marked as [pending](./pending-tests), and reported as such.
8+
Anything skipped will be marked as [pending](./pending-tests) and reported as such.
99
Here's an example of skipping an individual test:
1010

1111
```js
@@ -36,7 +36,7 @@ describe("Array", function () {
3636
});
3737
```
3838

39-
_Note_: Code in skipped suites, that is placed outside of hooks or tests is still executed, as mocha will still invoke the suite function to build up the suite structure for visualization.
39+
_Note_: Code in skipped suites that is placed outside of hooks or tests is still executed, as Mocha will still invoke the suite function to build up the suite structure for visualization.
4040

4141
:::tip[Best practice]
4242
Use `.skip()` instead of commenting tests out.

docs-next/src/content/docs/declaring/pending-tests.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe("Array", function () {
1414
});
1515
```
1616

17-
Pending tests will be included in the test results, and marked as pending.
17+
Pending tests will be included in the test results and marked as pending.
1818
A pending test is not considered a failed test.
1919

2020
Read the [inclusive tests section](./inclusive-tests) for an example of conditionally marking a test as pending via `this.skip()`.

docs-next/src/content/docs/declaring/retrying-tests.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This feature does re-run a failed test and its corresponding `beforeEach/afterEa
1111
`this.retries()` has no effect on failing hooks.
1212

1313
:::note
14-
Example below was written using Selenium webdriver (which [overwrites global Mocha hooks](https://github.com/SeleniumHQ/selenium/blob/c10e8a955883f004452cdde18096d70738397788/javascript/node/selenium-webdriver/testing/index.js) for `Promise` chain).
14+
The example below was written using Selenium webdriver (which [overwrites global Mocha hooks](https://github.com/SeleniumHQ/selenium/blob/c10e8a955883f004452cdde18096d70738397788/javascript/node/selenium-webdriver/testing/index.js) for `Promise` chain).
1515
:::
1616

1717
```js

docs-next/src/content/docs/explainers/test-fixture-decision-tree.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Helping you decide which API(s) to use for your test fixtures.
33
title: Test Fixture Decision Tree
44
---
55

6-
This flowchart will help you decide which of [hooks](../features/hooks), [root hook plugins](../features/root-hook-plugins) or [global fixtures](../features/global-fixtures) you should use.
6+
This flowchart will help you decide when to use [hooks](../features/hooks), [root hook plugins](../features/root-hook-plugins) or [global fixtures](../features/global-fixtures).
77

88
import FixtureWizard from "../../../components/FixtureWizard.astro";
99

docs-next/src/content/docs/features/assertions.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Assertions
44
---
55

66
Mocha allows you to use any assertion library you wish.
7-
In many of this site's examples, we're using Node.js' built-in [assert](https://nodejs.org/api/assert.html) module — but generally, if it throws an `Error`, it will work!
7+
In many of this site's examples, we're using Node.js' built-in [assert](https://nodejs.org/api/assert.html) module--but generally, if it throws an `Error`, it will work!
88
This means you can use libraries such as:
99

1010
- [better-assert](https://github.com/visionmedia/better-assert) - C-style self-documenting `assert()`

docs-next/src/content/docs/features/asynchronous-code.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ description: Testing asynchronous code with Mocha
33
title: Asynchronous Code
44
---
55

6-
By adding an argument (usually named `done`) to `it()` to a test callback, Mocha will know that it should wait for this function to be called to complete the test.
7-
This callback accepts both an `Error` instance (or subclass thereof) _or_ a falsy value; anything else is invalid usage and throws an error (usually causing a failed test).
6+
By adding an argument (usually named `done`) to a test callback, Mocha will know that it should wait for this function to be called to complete the test.
7+
This callback accepts both an `Error` instance _or_ a falsy value; anything else is invalid usage and throws an error (usually causing a failed test).
88

99
```js
1010
describe("User", function () {

docs-next/src/content/docs/features/hooks.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe("hooks", function () {
3030

3131
:::note
3232
Tests can appear before, after, or interspersed with your hooks.
33-
Hooks will run in the order they are defined, as appropriate; all `before()` hooks run (once), then any `beforeEach()` hooks, tests, any `afterEach()` hooks, and finally `after()` hooks (once).
33+
Hooks will run in the order they are defined, as appropriate: all `before()` hooks run (once), then any `beforeEach()` hooks, tests, any `afterEach()` hooks, and finally `after()` hooks (once).
3434
:::
3535

3636
## Describing Hooks

docs-next/src/content/docs/features/parallel-mode.mdx

+2-3
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ Here are a couple suggested workarounds:
112112

113113
1. `require('./setup.js')` or `import './setup.js'` at the top of every test file.
114114
Best avoided for those averse to boilerplate.
115-
1. _Recommended_: Define root hooks in a "required" file, using the new (also as
116-
of v8.0.0) [Root Hook Plugin](./root-hook-plugins) system.
115+
1. _Recommended_: Define root hooks in a "required" file, using the [Root Hook Plugin](./root-hook-plugins) system.
117116

118117
If you need to run some code _once and only once_, use a [global fixture](./global-fixtures) instead.
119118

@@ -133,7 +132,7 @@ If you find your tests don't work properly when run with [`--parallel`](../runni
133132
- ✅ Ensure you are using a [supported reporter](#reporter-limitations).
134133
- ✅ Ensure you are not using [other unsupported flags](#file-order-is-non-deterministic).
135134
- ✅ Double-check your [config file](../running/configuring); options set in config files will be merged with any command-line option.
136-
- ✅ Look for root hooks (they look like [this](#root-hooks-are-not-global)) in your tests.
135+
- ✅ Look for [root hooks](#root-hooks-are-not-global) in your tests.
137136
Move them into a [Root Hook Plugin](./root-hook-plugins).
138137
- ✅ Do any assertion, mock, or other test libraries you're consuming use root hooks? They may need to be [migrated](#migrating-a-library-to-use-root-hook-plugins) for compatibility with parallel mode.
139138
- ✅ If tests are unexpectedly timing out, you may need to increase the default test timeout (via [`--timeout`](../running/cli#--timeout-ms--t-ms))

docs-next/src/content/docs/features/root-hook-plugins.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For that reason, running root hooks using this method is _strongly discouraged_,
1414

1515
A _Root Hook Plugin_ is a JavaScript file loaded via [`--require`](../running/cli#--require-module--r-module) which "registers" one or more root hooks to be used across all test files.
1616

17-
In browsers you can set root hooks directly via a `rootHooks` object: `mocha.setup({ rootHooks: {beforeEach() {...}} })`, see [`mocha.setup()`](../running/browsers)
17+
In browsers you can set root hooks directly via a `rootHooks` object: `mocha.setup({ rootHooks: { beforeEach() {...} } })`, see [`mocha.setup()`](../running/browsers)
1818

1919
## Defining a Root Hook Plugin
2020

@@ -208,7 +208,7 @@ Your `test/hooks.js` (for this example, a CJS module) should contain:
208208
// test/hooks.js
209209

210210
exports.mochaHooks = {
211-
beforeEach: function () {
211+
beforeAll: function () {
212212
// global setup for all tests
213213
},
214214
afterAll: function () {

docs-next/src/content/docs/features/timeouts.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ With async tests if you disable timeouts via `this.timeout(0)` and then do not c
6464
## Diffs
6565

6666
Mocha supports the `err.expected` and `err.actual` properties of any thrown `AssertionError`s from an assertion library.
67-
Mocha will attempt to display the difference between what was expected, and what the assertion actually saw.
67+
Mocha will attempt to display the difference between what was expected and what the assertion actually saw.
6868
Here's an example of a "string" diff using `--inline-diffs`:
6969

7070
![string diffs](./reporter-string-diffs.png)

docs-next/src/content/docs/reporters/markdown.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ title: Markdown
66
Alias: `Markdown`, `markdown`
77

88
The Markdown reporter generates a markdown TOC and body for your test suite.
9-
This is great if you want to use the tests as documentation within a Github wiki page, or a markdown file in the repository that Github can render.
9+
This is great if you want to use the tests as documentation within a GitHub wiki page, or a markdown file in the repository that GitHub can render.
1010
For example, here is the Connect [test output](https://github.com/senchalabs/connect/blob/90a725343c2945aaee637e799b1cd11e065b2bff/tests.md).

docs-next/src/content/docs/reporters/xunit.mdx

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ title: XUnit
55

66
Alias: `XUnit`, `xunit`
77

8-
The XUnit reporter is also available.
9-
It outputs an XUnit-compatible XML document, often applicable in CI servers.
8+
The XUnit reporter outputs an XUnit-compatible XML document, often applicable in CI servers.
109

1110
By default, it will output to the console.
1211
To write directly to a file, use `--reporter-option output=filename.xml`.

docs-next/src/content/docs/running/browsers.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Running Mocha in Browsers
33
title: Browsers
44
---
55

6-
Mocha runs in the browser.
6+
Mocha can run in the browser.
77
Every release of Mocha will have new builds of `./mocha.js` and `./mocha.css` for use in the browser.
88

99
A typical setup might look something like the following, where we call `mocha.setup('bdd')` to use the **BDD** interface before loading the test scripts, running them `onload` with `mocha.run()`.

docs-next/src/content/docs/running/cli.mdx

+9-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ description: Running Mocha in your terminal.
55

66
Running `npx mocha --help` will show the full list of available commands:
77

8+
{/* This output is defined in lib/cli/run.js */}
9+
810
```plaintext
911
mocha [spec..]
1012
@@ -154,7 +156,7 @@ TL;DR: If your tests hang after an upgrade to Mocha v4.0.0 or newer, use `--exit
154156
:::
155157

156158
_Prior to_ version v4.0.0, _by default_, Mocha would force its own process to exit once it was finished executing all tests.
157-
This behavior enables a set of potential problems; it's indicative of tests (or fixtures, harnesses, code under test, etc.) which don't clean up after themselves properly.
159+
This behavior enables a set of potential problems: it's indicative of tests (or fixtures, harnesses, code under test, etc.) which don't clean up after themselves properly.
158160
Ultimately, "dirty" tests can (but not always) lead to _false positive_ or _false negative_ results.
159161

160162
"Hanging" most often manifests itself if a server is still listening on a port, or a socket is still open, etc.
@@ -163,7 +165,7 @@ It can also be something like a runaway `setInterval()`, or even an errant `Prom
163165
The _default behavior_ in v4.0.0 (and newer) is `--no-exit`, where previously it was `--exit`.
164166

165167
**The easiest way to "fix" the issue is to pass `--exit` to the Mocha process.**
166-
It _can_ be time-consuming to debug — because it's not always obvious where the problem is — but it _is_ recommended to do so.
168+
It _can_ be time-consuming to debug--because it's not always obvious where the problem is--but it _is_ recommended to do so.
167169

168170
To ensure your tests aren't leaving messes around, here are some ideas to get started:
169171

@@ -184,7 +186,7 @@ If set to `true`, Mocha returns exit code `0` even if there are failed tests dur
184186
:::note[New in v9.1.0]
185187
:::
186188

187-
Fail test run if no tests are encountered with `exit-code: 1`.
189+
Fail test run with `exit-code: 1` if no tests are encountered.
188190

189191
### `--forbid-only`
190192

@@ -478,7 +480,7 @@ Rerun tests on file changes.
478480

479481
The `--watch-files` and `--watch-ignore` options can be used to control which files are watched for changes.
480482

481-
Tests may be rerun manually by typing ⓡ ⓢ ⏎ (same shortcut as `nodemon`).
483+
Tests may be rerun manually by typing `rs` and pressing enter (same shortcut as `nodemon`).
482484

483485
### `--watch-files <file|directory|glob>`
484486

@@ -535,7 +537,7 @@ The same goes for any other part of a suite or test-case title, `--grep users` w
535537
And another option with double quotes: `--grep "groupA|groupB"`.
536538

537539
And for more complex criteria: `--grep "/get/i"`.
538-
Some shells as e.g. Git-Bash-for-Windows may require: `--grep "'/get/i'"`.
540+
Some shells (e.g. Git Bash for Windows) may require: `--grep "'/get/i'"`.
539541
Using flags other than the `ignoreCase /i` (especially `/g` and `/y`) may lead to unpredictable results.
540542

541543
```js
@@ -602,7 +604,7 @@ You can also pass `node` flags to Node.js using [`--node-option`](#--node-option
602604

603605
### `--enable-source-maps`
604606

605-
:::note[New in vNode.js v12.12.0]
607+
:::note[New in Node.js v12.12.0]
606608
:::
607609

608610
If the [`--enable-source-maps`](https://nodejs.org/dist/latest-v12.x/docs/api/cli.html#cli_enable_source_maps) flag
@@ -618,7 +620,7 @@ Error: cool
618620

619621
Prepend `--v8-` to any flag listed in the output of `node --v8-options` (excluding `--v8-options` itself) to use it.
620622

621-
V8 flags can be defined in Mocha's [configuration](./configuring).
623+
[V8](https://v8.dev/) flags can be defined in Mocha's [configuration](./configuring).
622624

623625
:::note[New in v9.1.0]
624626
You can also pass V8 flags (without `--v8-`) to Node.js using [`--node-option`](#--node-option-name--n-name).

docs-next/src/content/docs/running/configuring.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Mocha supports configuration files, typical of modern command-line tools, in sev
1212
in your project's root directory, and export an object (`module.exports = {/* ... */}`) containing your configuration.
1313
- **YAML**: Create a `.mocharc.yaml` (or `.mocharc.yml`) in your project's root directory.
1414
- **JSON**: Create a `.mocharc.json` (or `.mocharc.jsonc`) in your project's root directory.
15-
Comments &mdash; while not valid JSON &mdash; are allowed in this file, and will be ignored by Mocha.
15+
Comments--while not valid JSON--are allowed in this file, and will be ignored by Mocha.
1616
- **package.json**: Create a `mocha` property in your project's `package.json`.
1717

1818
## Custom Locations
@@ -29,7 +29,7 @@ Likewise, use `--no-package` to stop Mocha from looking for configuration in a `
2929

3030
## Priorities
3131

32-
If no custom path was given, and if there are multiple configuration files in the same directory, Mocha will search for &mdash; and use &mdash; only one.
32+
If no custom path was given, and if there are multiple configuration files in the same directory, Mocha will search for--and use--only one.
3333
The priority is:
3434

3535
1. `.mocharc.js`
@@ -65,7 +65,7 @@ For example, a `.mocharc.json` containing `"require": "bar"`, coupled with execu
6565
## Extending Configuration
6666

6767
Configurations can inherit from other modules using the `extends` keyword.
68-
See [here](http://yargs.js.org/docs/#api-reference-configobject-extends-keyword) for more information.
68+
See [yargs API reference](http://yargs.js.org/docs/#api-reference-configobject-extends-keyword) for more information.
6969

7070
## Configuration Format
7171

docs-next/src/content/docs/running/test-globs.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ You should _always_ quote your globs in npm scripts.
2424
If you use quotes, the [`glob`](https://www.npmjs.com/package/glob) module will handle its expansion.
2525
For maximum compatibility, surround the entire expression with double quotes and refrain from `$`, `"`, `^`, and `\` within your expression.
2626

27-
See this [tutorial](https://gist.github.com/reggi/475793ea1846affbcfe8) on using globs.
27+
See this [tutorial on using globs](https://gist.github.com/reggi/475793ea1846affbcfe8).
2828

2929
_Note_: Double quotes around the glob are recommended for portability.

0 commit comments

Comments
 (0)