Skip to content

Commit 90f9dae

Browse files
doc: document ESM configuration
1 parent 80c9387 commit 90f9dae

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ title: Configuring Mocha (Node.js)
99
Mocha supports configuration files, typical of modern command-line tools, in several formats:
1010

1111
- **JavaScript**: Create a `.mocharc.js` (or `.mocharc.cjs` when using [`"type"="module"`](/explainers/nodejs-native-esm-support) in your `package.json`)
12-
in your project's root directory, and export an object (`module.exports = {/* ... */}`) containing your configuration.
12+
in your project's root directory, and export an object (`module.exports = {/* ... */}`) containing your configuration. For native ESM and using `type="module"`
13+
or using `.mjs`, use a default export (`default export {/* ... */}`).
1314
- **YAML**: Create a `.mocharc.yaml` (or `.mocharc.yml`) in your project's root directory.
1415
- **JSON**: Create a `.mocharc.json` (or `.mocharc.jsonc`) in your project's root directory.
1516
Comments--while not valid JSON--are allowed in this file, and will be ignored by Mocha.

docs/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2254,7 +2254,9 @@ The HTML reporter is the default reporter when running Mocha in the browser. It
22542254
22552255
Mocha supports configuration files, typical of modern command-line tools, in several formats:
22562256

2257-
- **JavaScript**: Create a `.mocharc.js` (or `.mocharc.cjs` when using [`"type"="module"`](#nodejs-native-esm-support) in your `package.json`)
2257+
- **JavaScript**: Create a `.mocharc.js` (or `.mocharc.cjs` when using [`"type"="module"`](/explainers/nodejs-native-esm-support) in your `package.json`)
2258+
in your project's root directory, and export an object (`module.exports = {/* ... */}`) containing your configuration. For native ESM and using `type="module"`
2259+
or using `.mjs`, use a default export (`default export {/* ... */}`).
22582260
in your project's root directory, and export an object (`module.exports = {/* ... */}`) containing your configuration.
22592261
- **YAML**: Create a `.mocharc.yaml` (or `.mocharc.yml`) in your project's root directory.
22602262
- **JSON**: Create a `.mocharc.json` (or `.mocharc.jsonc`) in your project's root directory. Comments — while not valid JSON — are allowed in this file, and will be ignored by Mocha.

0 commit comments

Comments
 (0)