Skip to content

chore: convert CLI run command to ESM#6014

Open
macayu17 wants to merge 4 commits into
mochajs:mainfrom
macayu17:fix/5967-cli-esm
Open

chore: convert CLI run command to ESM#6014
macayu17 wants to merge 4 commits into
mochajs:mainfrom
macayu17:fix/5967-cli-esm

Conversation

@macayu17

Copy link
Copy Markdown

PR Checklist

Overview

Converts lib/cli/run.js to lib/cli/run.mjs as a small slice of the CLI ESM migration.

The run command now uses named exports for yargs (command, describe, builder, and handler), and commands.mjs re-exports it as the default run command namespace. I also updated the run command unit test to load run.mjs directly so this path stays covered.

I kept the other files from #5967 alone because they still have the require() / require.resolve() cases called out in the issue.

Checked with:

  • npm run test-smoke
  • npm run test-node:unit
  • npm run tsc
  • npm run clean; npm run build
  • npx eslint --max-warnings 0 lib/cli/run.mjs lib/cli/commands.mjs test/node-unit/cli/run.spec.js
  • npx prettier --check lib/cli/run.mjs lib/cli/commands.mjs test/node-unit/cli/run.spec.js

Copilot AI review requested due to automatic review settings May 24, 2026 16:43
@linux-foundation-easycla

linux-foundation-easycla Bot commented May 24, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: macayu17 / name: macayu17 (2eb1456)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR migrates Mocha’s default CLI run command module toward ESM usage and updates command exports/tests accordingly.

Changes:

  • Convert lib/cli/run.js from CommonJS (require/exports) to ESM (import/export).
  • Update CLI command re-exports to reference an ESM run module.
  • Add a unit test asserting the run command module is importable via ESM.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/node-unit/cli/run.spec.js Updates the test import path and adds an ESM-module availability test for the run command.
lib/cli/run.js Converts the run command implementation from CJS to ESM and updates imports/exports accordingly.
lib/cli/commands.mjs Switches the default run command export to reference an ESM module.

Comment thread test/node-unit/cli/run.spec.js Outdated
Comment thread lib/cli/commands.mjs Outdated
@codecov

codecov Bot commented May 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.87%. Comparing base (6695fba) to head (fcc7c7c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6014      +/-   ##
==========================================
- Coverage   80.89%   80.87%   -0.03%     
==========================================
  Files          64       64              
  Lines        4602     4596       -6     
  Branches      976      975       -1     
==========================================
- Hits         3723     3717       -6     
  Misses        879      879              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@macayu17
macayu17 force-pushed the fix/5967-cli-esm branch 2 times, most recently from 8d78b65 to bf7fde7 Compare May 25, 2026 04:10
@macayu17
macayu17 force-pushed the fix/5967-cli-esm branch from bf7fde7 to fcc7c7c Compare May 25, 2026 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants