Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b3b2ca8
feat!: change root package.json type to module
mark-wiemer Jun 17, 2026
d544ac9
npm run format:fix
JoshuaKGoldberg Jun 6, 2026
f6be57c
integration test fixes
JoshuaKGoldberg Jun 7, 2026
6b2d39b
Fixup eslint globalIgnores
mark-wiemer Jun 17, 2026
22938c6
Clarify setup.js references
mark-wiemer Jun 17, 2026
07fa510
Fixup Playwright tests
mark-wiemer Jun 17, 2026
f2fbf96
Change code sample to use `setup.js` not `.cjs`
mark-wiemer Jun 17, 2026
10e34fb
Remove stale Knip ignore
mark-wiemer Jun 17, 2026
245b935
Fix false negatives with ui.spec.cjs
mark-wiemer Jun 17, 2026
0035c43
Change remaining unit test files to *.cjs
mark-wiemer Jun 17, 2026
bbdeaf4
Fixup more renames for unit tests and jsapi test
mark-wiemer Jun 17, 2026
4b73d8d
Fixup global-fixtures spec and files
mark-wiemer Jun 17, 2026
a975d41
Rename config.mjs to config.js
mark-wiemer Jun 17, 2026
23ea2fd
Rename Playright files from mjs to js
mark-wiemer Jun 17, 2026
3875ae1
Make mocharc.js ESM, delete mocharc.mjs
mark-wiemer Jun 17, 2026
bc8c1ff
Fixup propagate fixture extension
mark-wiemer Jun 17, 2026
fe556c4
Clearly identify propagate fixture by exact name
mark-wiemer Jun 17, 2026
d963f42
Skip "w/o type=module" tests for now
mark-wiemer Jun 17, 2026
b896e03
Remove tests for old versions of node
mark-wiemer Jun 17, 2026
9570f61
Format
mark-wiemer Jun 17, 2026
2dea7d2
Remove unused semver reference
mark-wiemer Jun 17, 2026
883f124
Clarify semver usage
mark-wiemer Jun 17, 2026
df207c2
Clarify fixture package is CJS
mark-wiemer Jun 17, 2026
dcf5f3f
Fix CJS-specific tests in root-hooks spec
mark-wiemer Jun 17, 2026
ebb1f02
Remove unused `--require test/setup.cjs`
mark-wiemer Jun 17, 2026
0e881d4
Simplify `resolveFixturePath`
mark-wiemer Jun 17, 2026
aee6910
Restore broken parallel tests
mark-wiemer Jun 17, 2026
079a08c
Restore and adhere to `strict` lint rule
mark-wiemer Jun 17, 2026
c845cc2
Clarify name of /mocha.mjs
mark-wiemer Jun 17, 2026
3967436
Rename constants.mjs to constants.js
mark-wiemer Jun 17, 2026
2d849da
Rename esm-loader.fixture.mjs to *.js
mark-wiemer Jun 17, 2026
9d75f3a
Cleanup lint rules
mark-wiemer Jun 17, 2026
f9b2478
Remove support for .mjs fixtures
mark-wiemer Jun 17, 2026
910158e
Fix glob to run nested unit test
mark-wiemer Jun 18, 2026
402f64f
Add newline to end of (prettier-ignored) file
mark-wiemer Jun 18, 2026
774c48b
Remove stale Karma reference
mark-wiemer Jun 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Then:
1. Make sure the issue is labeled with [`status: accepting prs`](https://github.com/mochajs/mocha/issues?q=is%3Aissue+is%3Aopen+label%3A%22status%3A+accepting+prs%22)
1. Create a new branch in your working copy.
1. Make your changes and add them via `git add`.
- Your changes will likely be somewhere in `lib/`, `bin/`, or (if your changes are browser-specific) `browser-entry.mjs`.
- Your changes will likely be somewhere in `lib/`, `bin/`, or (if your changes are browser-specific) `browser-entry.js`.
- Unit and/or integration **tests are required** for any code change.
These live in `test/`.
- **Do not modify** the root `mocha.js` file directly; it is automatically generated.
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/01-bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ body:
validations:
required: true
- attributes:
description: What do `mocha --version`, `node_modules/.bin/mocha.mjs --version`, and `node --version` output? What name and version of browser/environment, shell, and any other related modules such as transpilers are you using?
description: What do `mocha --version`, `node_modules/.bin/mocha.js --version`, and `node --version` output? What name and version of browser/environment, shell, and any other related modules such as transpilers are you using?
label: Versions
type: textarea
validations:
Expand Down
6 changes: 3 additions & 3 deletions .knip.jsonc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"$schema": "https://unpkg.com/knip@6/schema-jsonc.json",
"entry": ["docs/_data/supporters.cjs", "index.mjs!", "lib/cli/index.js!"],
"entry": ["docs/_data/supporters.cjs", "index.js!", "lib/cli/index.cjs!"],
"project": ["{bin,lib,scripts,test}/**/*.{js,ts,mjs,cjs}"],
"ignore": [
"test/integration/fixtures/esm/type-module/test-that-imports-non-existing-module.fixture.js",
"test/integration/fixtures/options/watch/test-with-dependency.fixture.js",
"test/integration/fixtures/options/watch/test-with-dependency.fixture.cjs",
],
"ignoreDependencies": [
"@test/esm-only-loader",
Expand All @@ -16,7 +16,7 @@
"entry": ["test/**/*.{js,ts,mjs,cjs}"],
},
"webpack": {
"config": "test/browser-specific/fixtures/webpack/webpack.config.js",
"config": "test/browser-specific/fixtures/webpack/webpack.config.cjs",
},
"rules": {
"exports": "off",
Expand Down
2 changes: 1 addition & 1 deletion .mocharc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require: "test/setup"
require: "./test/setup.cjs"
ui: "bdd"
global:
- "okGlobalA,okGlobalB"
Expand Down
2 changes: 1 addition & 1 deletion .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"**/package-lock.json",
"node_modules/**",
"scripts/**",
"!test/integration/fixtures/stack-trace.fixture.js"
"!test/integration/fixtures/stack-trace.fixture.cjs"
]
}
10 changes: 5 additions & 5 deletions .wallaby.js → .wallaby.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module.exports = () => {
files: [
"index.js",
"lib/**/*.{js,json}",
"test/setup.js",
"test/assertions.js",
"test/setup.cjs",
"test/assertions.cjs",
{
pattern: "test/node-unit/**/*.fixture.js",
instrument: false,
Expand All @@ -21,8 +21,8 @@ module.exports = () => {
],
filesWithNoCoverageCalculated: [
"test/**/*.fixture.js",
"test/setup.js",
"test/assertions.js",
"test/setup.cjs",
"test/assertions.cjs",
"lib/browser/**/*.js",
],
tests: ["test/unit/**/*.spec.js", "test/node-unit/**/*.spec.js"],
Expand All @@ -46,7 +46,7 @@ module.exports = () => {
"",
mochaUnderTest,
);
require("./test/setup");
require("./test/setup.cjs");
},
debug: true,
runMode: "onsave",
Expand Down
12 changes: 6 additions & 6 deletions bin/mocha.mjs → bin/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* This wrapper executable checks for known node flags and appends them when found,
* before invoking the "real" executable (`lib/cli/cli.mjs`)
* before invoking the "real" executable (`lib/cli/cli.js`)
*
* @module bin/mocha
* @private
Expand All @@ -13,14 +13,14 @@ import { spawn } from "node:child_process";
import os from "node:os";
import unparse from "yargs-unparser";

import { main } from "../lib/cli/cli.mjs";
import { loadOptions } from "../lib/cli/options.mjs";
import { main } from "../lib/cli/cli.js";
import { loadOptions } from "../lib/cli/options.cjs";
import {
unparseNodeFlags,
isNodeFlag,
impliesNoTimeouts,
} from "../lib/cli/node-flags.mjs";
import { aliases } from "../lib/cli/run-option-metadata.mjs";
} from "../lib/cli/node-flags.cjs";
import { aliases } from "../lib/cli/run-option-metadata.cjs";
import { fileURLToPath } from "node:url";

const debug = d.debug("mocha:cli:mocha");
Expand Down Expand Up @@ -84,7 +84,7 @@ if (mochaArgs._) {
}

if (mochaArgs["node-option"] || Object.keys(nodeArgs).length || hasInspect) {
const mochaPath = fileURLToPath(import.meta.resolve("../lib/cli/cli.mjs"));
const mochaPath = fileURLToPath(import.meta.resolve("../lib/cli/cli.js"));

const nodeArgv =
(mochaArgs["node-option"] &&
Expand Down
6 changes: 3 additions & 3 deletions browser-entry.mjs → browser-entry.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BrowserStdout from "browser-stdout";

import { parseQuery } from "./lib/browser/parse-query.mjs";
import { highlightTags } from "./lib/browser/highlight-tags.mjs";
import Mocha from "./lib/mocha.js";
import { parseQuery } from "./lib/browser/parse-query.js";
import { highlightTags } from "./lib/browser/highlight-tags.js";
import Mocha from "./lib/mocha.cjs";

/**
* Shim process.stdout.
Expand Down
3 changes: 1 addition & 2 deletions docs/.knip.jsonc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"$schema": "https://unpkg.com/knip@6/schema-jsonc.json",
// Entry points marked with ! are analyzed but not reported as unused
"entry": ["src/content/**/*.{mdx,ts}!", "src/content.config.ts"],
"entry": ["src/content/**/*.{mdx,ts}!"],
"project": ["src/**/*.{ts,js,mjs,cjs,astro}"],
"astro": {
"config": "astro.config.ts",
Expand Down
48 changes: 0 additions & 48 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions docs/public/example/Array.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use strict";

describe("Array", function () {
describe(".push()", function () {
it("should append a value", function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ it("double done", function (done) {
Running the above test will give you the below error message:

```bash
$ ./node_modules/.bin/mocha.mjs mocha.test.js
$ ./node_modules/.bin/mocha.js mocha.test.js


✓ double done
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/explainers/programmatic-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mocha.run(function (failures) {
});
```

`mocha.run()` returns a `Runner` instance which emits many [events](https://github.com/mochajs/mocha/blob/main/lib/runner.js) of interest, exposed as `Mocha.Runner.constants` (e.g. `EVENT_TEST_PASS`, `EVENT_TEST_FAIL`, `EVENT_RUN_END`).
`mocha.run()` returns a `Runner` instance which emits many [events](https://github.com/mochajs/mocha/blob/main/lib/runner.cjs) of interest, exposed as `Mocha.Runner.constants` (e.g. `EVENT_TEST_PASS`, `EVENT_TEST_FAIL`, `EVENT_RUN_END`).

Note that `run` (via `loadFiles`, which it calls) relies on Node's `require` to execute the test interface functions. Thus, files loaded by Mocha will be stored in Node's `require` cache and therefore tests in these files will not be re-run if `mocha.run()` is called again. If you want to run tests multiple times, you may need to clear Node's `require` cache before subsequent calls in whichever manner best suits your needs. `Mocha#unloadFiles` is also available and will remove all files loaded by `Mocha#loadFiles`.

Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/explainers/third-party-uis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ In this first brief example, we'll create an interface with only a single functi

```javascript
import Mocha from "mocha";
import { createCommon as MochaInterface } from "mocha/lib/interfaces/common.mjs";
import { createCommon as MochaInterface } from "mocha/lib/interfaces/common.js";

const Test = Mocha.Test;
/**
Expand Down Expand Up @@ -74,7 +74,7 @@ In this next example, we'll be extending the [TDD interface](https://github.com/

```javascript
import Mocha from "mocha";
import { createCommon as MochaInterface } from "mocha/lib/interfaces/common.mjs";
import { createCommon as MochaInterface } from "mocha/lib/interfaces/common.js";
import escapeStringRegexp from "escape-string-regexp";

const Test = Mocha.Test;
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ In addition to chatting with us on [our Discord](https://discord.gg/KeDn2uXhER),
spies, mocking, and shared behaviours be sure to check out the [Mocha Wiki](https://github.com/mochajs/mocha/wiki) on GitHub.
For a running example of Mocha, view [example/tests.html](example/tests.html).

For the JavaScript API, view the [API documentation](/api) or the [source](https://github.com/mochajs/mocha/blob/main/lib/mocha.js).
For the JavaScript API, view the [API documentation](/api) or the [source](https://github.com/mochajs/mocha/blob/main/lib/mocha.cjs).

<ClientRedirects />
2 changes: 1 addition & 1 deletion docs/src/content/docs/running/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Running Mocha in your terminal.

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

{/* This output is defined in lib/cli/run.js */}
{/* This output is defined in lib/cli/run.cjs */}

```plaintext
mocha [spec..]
Expand Down
Loading
Loading