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
This is the new site, hosted at https://mochajs.org/next and built with [Astro Starlight](https://starlight.astro.build). For details on how to build alongside the old site, see the `docs` directory.
4
+
5
+
To run this site alone:
4
6
5
7
```shell
8
+
cd docs-next
6
9
npm i
7
10
npm run generate
8
11
npm run dev
9
12
```
10
13
11
-
To merge with the old site:
12
-
13
-
```shell
14
-
npm i
15
-
npm run build-with-old
16
-
```
17
-
18
-
To preview the old and new site:
19
-
20
-
```shell
21
-
cd .. # back to root dir
22
-
npm run docs:preview
23
-
```
24
-
25
-
The new site will be at `http://localhost:8080/next`
14
+
However, note that relative links may resolve with `dev` but fail with `build` and `preview` (see https://github.com/mochajs/mocha/issues/5415).
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/explainers/run-cycle-overview.mdx
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,35 +11,35 @@ In a browser, test files are loaded by `<script>` tags, and calling `mocha.run()
11
11
12
12
1. User (that's you) executes `mocha`
13
13
2. Loads options from config files, if present
14
-
3. Mocha processes any command-line options provided (see section on [configuration merging](../running/configuring#merging) for details)
14
+
3. Mocha processes any command-line options provided (see section on [configuration merging](/next/running/configuring#merging) for details)
15
15
4. If known flags for the `node` executable are found:
16
16
1. Mocha will spawn `node` in a child process, executing itself with these flags
17
17
2. Otherwise, Mocha does not spawn a child process
18
18
5. Mocha loads modules specified by `--require`
19
-
1. If a file loaded this way contains known Mocha-specific exports (e.g., [root hook plugins](../features/root-hook-plugins)), Mocha "registers" these
19
+
1. If a file loaded this way contains known Mocha-specific exports (e.g., [root hook plugins](/next/features/root-hook-plugins)), Mocha "registers" these
20
20
2. If not, Mocha ignores any exports of a `--require`'d module
21
21
6. Mocha validates any custom reporters or interfaces which were loaded via `--require` or otherwise
22
22
7. Mocha _discovers_ test files; when given no files or directories, it finds files with extensions `.js`, `.mjs` or `.cjs` in the `test` directory (but not its children), relative to the current working directory
23
-
8. The (default) [bdd interface](../interfaces/bdd) loads the test files _in no particular order_, which are given an interface-specific `global` context (this is how, e.g., `describe()` ends up as a global in a test file)
23
+
8. The (default) [bdd interface](/next/interfaces/bdd) loads the test files _in no particular order_, which are given an interface-specific `global` context (this is how, e.g., `describe()` ends up as a global in a test file)
24
24
1. When a test file is loaded, Mocha executes all of its suites and finds--_but does not execute_--any hooks and tests therein.
25
25
2. Top-level hooks, tests and suites are all made members of an "invisible" _root suite_; there is only _one_ root suite for the entire process
26
-
9. Mocha runs [global setup fixtures](../features/global-fixtures#global-setup-fixtures), if any
26
+
9. Mocha runs [global setup fixtures](/next/features/global-fixtures#global-setup-fixtures), if any
27
27
10. Starting with the "root" suite, Mocha executes:
28
-
11. Any "before all" hooks (for the _root_ suite, this only happens once; see [root hook plugins](../features/root-hook-plugins))
28
+
11. Any "before all" hooks (for the _root_ suite, this only happens once; see [root hook plugins](/next/features/root-hook-plugins))
29
29
12. For each test, Mocha executes:
30
30
1. Any "before each" hooks
31
31
2. The test (and reports the result)
32
32
3. Any "after each" hooks
33
33
13. If the current suite has a child suite, repeat the steps in 10. for each child suite; each child suite _inherits_ any "before each" and "after each" hooks defined in its parent
34
-
14. Any "after all" hooks (for the _root_ suite, this only happens once; see [root hook plugins](../features/root-hook-plugins))
34
+
14. Any "after all" hooks (for the _root_ suite, this only happens once; see [root hook plugins](/next/features/root-hook-plugins))
35
35
15. Mocha prints a final summary/epilog, if applicable
36
-
16. Mocha runs [global teardown fixtures](../features/global-fixtures#global-teardown-fixtures), if any
36
+
16. Mocha runs [global teardown fixtures](/next/features/global-fixtures#global-teardown-fixtures), if any
37
37
38
38
## Parallel Mode
39
39
40
40
1. Repeat steps 1 through 6 from [Serial Mode](#serial-mode) above, skipping reporter validation
41
41
2. All test files found are put into a queue (they are _not_ loaded by the main process)
42
-
3. Mocha runs [global setup fixtures](../features/global-fixtures#global-setup-fixtures), if any
42
+
3. Mocha runs [global setup fixtures](/next/features/global-fixtures#global-setup-fixtures), if any
43
43
4. Mocha creates a pool of subprocesses ("workers")
44
44
5._Immediately before_ a worker runs the first test it receives, the worker "bootstraps" itself by:
45
45
1. Loading all `--require`'d modules
@@ -52,4 +52,4 @@ In a browser, test files are loaded by `<script>` tags, and calling `mocha.run()
52
52
9. When the worker completes the test file, buffered results are returned to the main process, which then gives them to the user-specified reporter (`spec` by default)
53
53
10. The worker makes itself available to the pool; the pool gives the worker another test file to run, if any remain
54
54
11. Mocha prints a final summary/epilog, if applicable
55
-
12. Mocha runs [global teardown fixtures](../features/global-fixtures#global-teardown-fixtures), if any
55
+
12. Mocha runs [global teardown fixtures](/next/features/global-fixtures#global-teardown-fixtures), if any
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/explainers/test-fixture-decision-tree.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
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 when to use [hooks](../features/hooks), [root hook plugins](../features/root-hook-plugins) or [global fixtures](../features/global-fixtures).
6
+
This flowchart will help you decide when to use [hooks](/next/features/hooks), [root hook plugins](/next/features/root-hook-plugins) or [global fixtures](/next/features/global-fixtures).
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/features/global-fixtures.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ title: Global Fixtures
6
6
:::note[New in v8.2.0]
7
7
:::
8
8
9
-
At first glance, _global fixtures_ seem similar to [root hook plugins](./root-hook-plugins).
9
+
At first glance, _global fixtures_ seem similar to [root hook plugins](/next/features/root-hook-plugins).
10
10
However, unlike root hooks, global fixtures:
11
11
12
12
1. Are _guaranteed_ to execute _once and only once_
@@ -44,7 +44,7 @@ export async function mochaGlobalSetup() {
44
44
To use it, load this file when running Mocha via `mocha --require fixtures.cjs` (or whatever you have named the file).
45
45
46
46
:::tip
47
-
Remember: you can define "requires" in a [configuration file](../running/configuring).
47
+
Remember: you can define "requires" in a [configuration file](/next/running/configuring).
48
48
:::
49
49
50
50
Now, before Mocha loads and runs your tests, it will execute the above global setup fixture, starting a server for testing.
@@ -96,7 +96,7 @@ You could be clever and try to get around this restriction by assigning somethin
96
96
It's probably best to play by the rules!
97
97
:::
98
98
99
-
Instead, use the global fixture to _start_ the database, and use [root hook plugins](./root-hook-plugins) or plain old [hooks](./hooks) to create a connection.
99
+
Instead, use the global fixture to _start_ the database, and use [root hook plugins](/next/features/root-hook-plugins) or plain old [hooks](/next/features/hooks) to create a connection.
100
100
101
101
Here's an example of using global fixtures and "before all" hooks to get the job done.
102
102
Note that we do not reference the `server` object anywhere in our tests!
Copy file name to clipboardExpand all lines: docs-next/src/content/docs/features/hooks.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,12 +87,12 @@ describe("Connection", function () {
87
87
88
88
A hook defined at the top scope of a test file (outside of a suite) is a _root hook_.
89
89
90
-
As of v8.0.0, [Root Hook Plugins](./root-hook-plugins) are the preferred mechanism for setting root hooks.
90
+
As of v8.0.0, [Root Hook Plugins](/next/features/root-hook-plugins) are the preferred mechanism for setting root hooks.
91
91
92
92
## Delayed Root Suite
93
93
94
94
:::caution
95
-
Delayed root suites are incompatible with [parallel mode](./parallel-mode).
95
+
Delayed root suites are incompatible with [parallel mode](/next/features/parallel-mode).
96
96
:::
97
97
98
98
If you need to perform asynchronous operations before any of your suites are run (e.g. for dynamically generating tests), you may delay the root suite.
0 commit comments