Skip to content

Commit b2bc769

Browse files
authored
docs: fix links in new site (#5416)
1 parent f31ce8f commit b2bc769

17 files changed

+77
-87
lines changed

docs-next/README.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
1-
# Mocha Docs vNext: Built on Astro Starlight
1+
# Mocha Docs: Built on Astro Starlight
22

3-
After `cd`ing into this directory:
3+
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:
46

57
```shell
8+
cd docs-next
69
npm i
710
npm run generate
811
npm run dev
912
```
1013

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).

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe("add()", function () {
6262

6363
With `top-level await` you can collect your test data in a dynamic and asynchronous way while the test file is being loaded.
6464

65-
See also [`--delay`](../features/hooks#delayed-root-suite) for CommonJS modules without `top-level await`.
65+
See also [`--delay`](/next/features/hooks#delayed-root-suite) for CommonJS modules without `top-level await`.
6666

6767
```js
6868
// testfile.mjs

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Exclusive Tests
44
---
55

66
:::caution
7-
Exclusive tests are incompatible with [parallel mode](../features/parallel-mode).
7+
Exclusive tests are incompatible with [parallel mode](/next/features/parallel-mode).
88
:::
99

1010
The exclusivity feature allows you to run _only_ the specified suite or test-case

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

Lines changed: 2 additions & 2 deletions
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](/next/declaring/pending-tests) and reported as such.
99
Here's an example of skipping an individual test:
1010

1111
```js
@@ -56,7 +56,7 @@ it('should only test in the correct environment', function() {
5656
});
5757
```
5858

59-
The above test will be reported as [pending](./pending-tests).
59+
The above test will be reported as [pending](/next/declaring/pending-tests).
6060
It's also important to note that calling `this.skip()` will effectively _abort_ the test.
6161

6262
:::tip[Best practice]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ describe("Array", function () {
1717
Pending tests will be included in the test results and marked as pending.
1818
A pending test is not considered a failed test.
1919

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

docs-next/src/content/docs/explainers/nodejs-native-esm-support.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ More information can be found in the [Node.js documentation](https://nodejs.org/
2626

2727
### Current Limitations
2828

29-
- [Watch mode](../running/cli#--watch--w) does not support ES Module test files
30-
- [Custom reporters](../reporters/third-party) and [custom interfaces](../interfaces/third-party) can only be CommonJS files
31-
- [Configuration file](../running/configuring) can only be a CommonJS file (`.mocharc.js` or `.mocharc.cjs`)
29+
- [Watch mode](/next/running/cli#--watch--w) does not support ES Module test files
30+
- [Custom reporters](/next/reporters/third-party) and [custom interfaces](/next/interfaces/third-party) can only be CommonJS files
31+
- [Configuration file](/next/running/configuring) can only be a CommonJS file (`.mocharc.js` or `.mocharc.cjs`)
3232
- Mocha in Node.js version 24.4.0 or older [silently ignored top level errors in ESM files](https://github.com/mochajs/mocha/issues/5396).
3333
If you cannot upgrade to a newer Node.js version, you can add `--no-experimental-require-module` to the `NODE_OPTIONS` environment variable.
3434
- When using module-level mocks via libs like `proxyquire`, `rewiremock` or `rewire`, hold off on using ES modules for your test files.

docs-next/src/content/docs/explainers/run-cycle-overview.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,35 @@ In a browser, test files are loaded by `<script>` tags, and calling `mocha.run()
1111

1212
1. User (that's you) executes `mocha`
1313
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)
1515
4. If known flags for the `node` executable are found:
1616
1. Mocha will spawn `node` in a child process, executing itself with these flags
1717
2. Otherwise, Mocha does not spawn a child process
1818
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
2020
2. If not, Mocha ignores any exports of a `--require`'d module
2121
6. Mocha validates any custom reporters or interfaces which were loaded via `--require` or otherwise
2222
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)
2424
1. When a test file is loaded, Mocha executes all of its suites and finds--_but does not execute_--any hooks and tests therein.
2525
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
2727
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))
2929
12. For each test, Mocha executes:
3030
1. Any "before each" hooks
3131
2. The test (and reports the result)
3232
3. Any "after each" hooks
3333
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))
3535
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
3737

3838
## Parallel Mode
3939

4040
1. Repeat steps 1 through 6 from [Serial Mode](#serial-mode) above, skipping reporter validation
4141
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
4343
4. Mocha creates a pool of subprocesses ("workers")
4444
5. _Immediately before_ a worker runs the first test it receives, the worker "bootstraps" itself by:
4545
1. Loading all `--require`'d modules
@@ -52,4 +52,4 @@ In a browser, test files are loaded by `<script>` tags, and calling `mocha.run()
5252
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)
5353
10. The worker makes itself available to the pool; the pool gives the worker another test file to run, if any remain
5454
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

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

Lines changed: 1 addition & 1 deletion
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 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).
77

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

docs-next/src/content/docs/features/global-fixtures.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Global Fixtures
66
:::note[New in v8.2.0]
77
:::
88

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).
1010
However, unlike root hooks, global fixtures:
1111

1212
1. Are _guaranteed_ to execute _once and only once_
@@ -44,7 +44,7 @@ export async function mochaGlobalSetup() {
4444
To use it, load this file when running Mocha via `mocha --require fixtures.cjs` (or whatever you have named the file).
4545

4646
:::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).
4848
:::
4949

5050
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
9696
It's probably best to play by the rules!
9797
:::
9898

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.
100100

101101
Here's an example of using global fixtures and "before all" hooks to get the job done.
102102
Note that we do not reference the `server` object anywhere in our tests!

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ describe("Connection", function () {
8787

8888
A hook defined at the top scope of a test file (outside of a suite) is a _root hook_.
8989

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.
9191

9292
## Delayed Root Suite
9393

9494
:::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).
9696
:::
9797

9898
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

Comments
 (0)