From 28ef8bc5309cb3d0823cfca502b0aa9b3312c3c7 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Wed, 5 Nov 2025 06:30:42 -0700 Subject: [PATCH 1/5] feat: add mocha.mjs export --- mocha.mjs | 24 ++++++++++++++++++++++++ package.json | 1 + 2 files changed, 25 insertions(+) create mode 100644 mocha.mjs diff --git a/mocha.mjs b/mocha.mjs new file mode 100644 index 0000000000..91c46d82c2 --- /dev/null +++ b/mocha.mjs @@ -0,0 +1,24 @@ +import "./mocha.js" + +const { mocha } = globalThis; + +const describe = mocha.describe.bind(mocha); +const context = mocha.context.bind(mocha); +const it = mocha.it.bind(mocha); +const specify = mocha.specify.bind(mocha); +const xdescribe = mocha.xdescribe.bind(mocha); +const xcontext = mocha.xcontext.bind(mocha); +const xit = mocha.xit.bind(mocha); +const xspecify = mocha.xspecify.bind(mocha); +const before = mocha.before.bind(mocha); +const beforeEach = mocha.beforeEach.bind(mocha); +const afterEach = mocha.afterEach.bind(mocha); +const after = mocha.after.bind(mocha); + +const setup = mocha.setup.bind(mocha); +const run = mocha.run.bind(mocha); + +export { + describe, context, it, specify, xdescribe, xcontext, + xit, xspecify, before, beforeEach, afterEach, after, setup, run +}; diff --git a/package.json b/package.json index 2ca471c06f..1bdaa51447 100644 --- a/package.json +++ b/package.json @@ -190,6 +190,7 @@ "mocha.css", "mocha.js", "mocha.js.map", + "mocha.mjs", "browser-entry.js" ], "browser": { From e405d8587085f3102d42cc9016fb02207111c6f6 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sat, 8 Nov 2025 16:49:40 -0700 Subject: [PATCH 2/5] chore: lint .mjs always as modules --- eslint.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eslint.config.js b/eslint.config.js index 10d4ad1372..49495fcaec 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -89,7 +89,7 @@ module.exports = [ }, }, { - files: ["test/**/*.mjs"], + files: ["**/*.mjs"], languageOptions: { sourceType: "module", }, From 5a07936b07dff8f89338c7aa4a3865f98f8dc22a Mon Sep 17 00:00:00 2001 From: Mark Wiemer Date: Thu, 13 Nov 2025 20:29:44 -0800 Subject: [PATCH 3/5] Ignore missing import error, format file --- mocha.mjs | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/mocha.mjs b/mocha.mjs index 91c46d82c2..acd517f4b1 100644 --- a/mocha.mjs +++ b/mocha.mjs @@ -1,24 +1,35 @@ -import "./mocha.js" +/* eslint-disable-next-line n/no-missing-import */ +import "./mocha.js"; const { mocha } = globalThis; - -const describe = mocha.describe.bind(mocha); +const after = mocha.after.bind(mocha); +const afterEach = mocha.afterEach.bind(mocha); +const before = mocha.before.bind(mocha); +const beforeEach = mocha.beforeEach.bind(mocha); const context = mocha.context.bind(mocha); +const describe = mocha.describe.bind(mocha); const it = mocha.it.bind(mocha); +const run = mocha.run.bind(mocha); +const setup = mocha.setup.bind(mocha); const specify = mocha.specify.bind(mocha); -const xdescribe = mocha.xdescribe.bind(mocha); const xcontext = mocha.xcontext.bind(mocha); +const xdescribe = mocha.xdescribe.bind(mocha); const xit = mocha.xit.bind(mocha); const xspecify = mocha.xspecify.bind(mocha); -const before = mocha.before.bind(mocha); -const beforeEach = mocha.beforeEach.bind(mocha); -const afterEach = mocha.afterEach.bind(mocha); -const after = mocha.after.bind(mocha); - -const setup = mocha.setup.bind(mocha); -const run = mocha.run.bind(mocha); export { - describe, context, it, specify, xdescribe, xcontext, - xit, xspecify, before, beforeEach, afterEach, after, setup, run + after, + afterEach, + before, + beforeEach, + context, + describe, + it, + run, + setup, + specify, + xcontext, + xdescribe, + xit, + xspecify, }; From 91e56f71a7edaf5c44aace100e62a9fa767cf655 Mon Sep 17 00:00:00 2001 From: Mark Wiemer Date: Thu, 13 Nov 2025 20:31:10 -0800 Subject: [PATCH 4/5] Document why we ignore that missing import --- mocha.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/mocha.mjs b/mocha.mjs index acd517f4b1..a6d389ff9b 100644 --- a/mocha.mjs +++ b/mocha.mjs @@ -1,3 +1,4 @@ +// this build file is not committed to the repo /* eslint-disable-next-line n/no-missing-import */ import "./mocha.js"; From b86a9073b354927e9b44309f7cadb8d8bf5c6d7a Mon Sep 17 00:00:00 2001 From: Mark Wiemer Date: Thu, 13 Nov 2025 20:31:24 -0800 Subject: [PATCH 5/5] fix typo --- mocha.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mocha.mjs b/mocha.mjs index a6d389ff9b..2f90c72d6b 100644 --- a/mocha.mjs +++ b/mocha.mjs @@ -1,4 +1,4 @@ -// this build file is not committed to the repo +// this built file is not committed to the repo /* eslint-disable-next-line n/no-missing-import */ import "./mocha.js";