You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/declaring/dynamic-tests.mdx
+2-2
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ title: Dynamic Tests
4
4
---
5
5
6
6
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.
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/declaring/inclusive-tests.mdx
+2-2
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ title: Inclusive Tests
5
5
6
6
This feature is the inverse of `.only()`.
7
7
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.
9
9
Here's an example of skipping an individual test:
10
10
11
11
```js
@@ -36,7 +36,7 @@ describe("Array", function () {
36
36
});
37
37
```
38
38
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.
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/declaring/retrying-tests.mdx
+1-1
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ This feature does re-run a failed test and its corresponding `beforeEach/afterEa
11
11
`this.retries()` has no effect on failing hooks.
12
12
13
13
:::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).
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/explainers/test-fixture-decision-tree.mdx
+1-1
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ description: Helping you decide which API(s) to use for your test fixtures.
3
3
title: Test Fixture Decision Tree
4
4
---
5
5
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).
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/features/assertions.mdx
+1-1
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ title: Assertions
4
4
---
5
5
6
6
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!
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/features/asynchronous-code.mdx
+2-2
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,8 @@ description: Testing asynchronous code with Mocha
3
3
title: Asynchronous Code
4
4
---
5
5
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).
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/features/hooks.mdx
+1-1
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ describe("hooks", function () {
30
30
31
31
:::note
32
32
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).
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/features/parallel-mode.mdx
+2-3
Original file line number
Diff line number
Diff line change
@@ -112,8 +112,7 @@ Here are a couple suggested workarounds:
112
112
113
113
1.`require('./setup.js')` or `import './setup.js'` at the top of every test file.
114
114
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.
117
116
118
117
If you need to run some code _once and only once_, use a [global fixture](./global-fixtures) instead.
119
118
@@ -133,7 +132,7 @@ If you find your tests don't work properly when run with [`--parallel`](../runni
133
132
- ✅ Ensure you are using a [supported reporter](#reporter-limitations).
134
133
- ✅ Ensure you are not using [other unsupported flags](#file-order-is-non-deterministic).
135
134
- ✅ 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.
137
136
Move them into a [Root Hook Plugin](./root-hook-plugins).
138
137
- ✅ 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.
139
138
- ✅ If tests are unexpectedly timing out, you may need to increase the default test timeout (via [`--timeout`](../running/cli#--timeout-ms--t-ms))
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/features/root-hook-plugins.mdx
+2-2
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ For that reason, running root hooks using this method is _strongly discouraged_,
14
14
15
15
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.
16
16
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)
18
18
19
19
## Defining a Root Hook Plugin
20
20
@@ -208,7 +208,7 @@ Your `test/hooks.js` (for this example, a CJS module) should contain:
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/running/browsers.mdx
+1-1
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ description: Running Mocha in Browsers
3
3
title: Browsers
4
4
---
5
5
6
-
Mocha runs in the browser.
6
+
Mocha can run in the browser.
7
7
Every release of Mocha will have new builds of `./mocha.js` and `./mocha.css` for use in the browser.
8
8
9
9
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()`.
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/running/cli.mdx
+9-7
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,8 @@ description: Running Mocha in your terminal.
5
5
6
6
Running `npx mocha --help` will show the full list of available commands:
7
7
8
+
{/* This output is defined in lib/cli/run.js */}
9
+
8
10
```plaintext
9
11
mocha [spec..]
10
12
@@ -154,7 +156,7 @@ TL;DR: If your tests hang after an upgrade to Mocha v4.0.0 or newer, use `--exit
154
156
:::
155
157
156
158
_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.
158
160
Ultimately, "dirty" tests can (but not always) lead to _false positive_ or _false negative_ results.
159
161
160
162
"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
163
165
The _default behavior_ in v4.0.0 (and newer) is `--no-exit`, where previously it was `--exit`.
164
166
165
167
**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.
167
169
168
170
To ensure your tests aren't leaving messes around, here are some ideas to get started:
169
171
@@ -184,7 +186,7 @@ If set to `true`, Mocha returns exit code `0` even if there are failed tests dur
184
186
:::note[New in v9.1.0]
185
187
:::
186
188
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.
188
190
189
191
### `--forbid-only`
190
192
@@ -478,7 +480,7 @@ Rerun tests on file changes.
478
480
479
481
The `--watch-files` and `--watch-ignore` options can be used to control which files are watched for changes.
480
482
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`).
482
484
483
485
### `--watch-files <file|directory|glob>`
484
486
@@ -535,7 +537,7 @@ The same goes for any other part of a suite or test-case title, `--grep users` w
535
537
And another option with double quotes: `--grep "groupA|groupB"`.
536
538
537
539
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. GitBashforWindows) may require: `--grep "'/get/i'"`.
539
541
Using flags other than the `ignoreCase /i` (especially `/g` and `/y`) may lead to unpredictable results.
540
542
541
543
```js
@@ -602,7 +604,7 @@ You can also pass `node` flags to Node.js using [`--node-option`](#--node-option
602
604
603
605
### `--enable-source-maps`
604
606
605
-
:::note[New in vNode.js v12.12.0]
607
+
:::note[New in Node.js v12.12.0]
606
608
:::
607
609
608
610
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
618
620
619
621
Prepend `--v8-` to any flag listed in the output of `node --v8-options` (excluding `--v8-options` itself) to use it.
620
622
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).
622
624
623
625
:::note[New in v9.1.0]
624
626
You can also pass V8 flags (without `--v8-`) to Node.js using [`--node-option`](#--node-option-name--n-name).
0 commit comments