Skip to content

test: load the mocha-error esm-utils fixture as .cts#6160

Open
mostafaNazari702 wants to merge 1 commit into
mochajs:mainfrom
mostafaNazari702:esm-utils-cts-fixture
Open

test: load the mocha-error esm-utils fixture as .cts#6160
mostafaNazari702 wants to merge 1 commit into
mochajs:mainfrom
mostafaNazari702:esm-utils-cts-fixture

Conversation

@mostafaNazari702

@mostafaNazari702 mostafaNazari702 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

Overview

An issue that i filed: #6156, we fix here by renaming the mock-mocha-forbidden-exclusivity-err fixture from .ts to .cts.

fixture uses require(), and after #6078 changed the root package.json to "type": "module", Node started loading the .ts file as ESM, that made "require" unavailable so the test failed with a ReferenceError instead of ERR_MOCHA_FORBIDDEN_EXCLUSIVITY.

Having it as .cts keeps it as CommonJS regardless of the root type setting and we preserve the same require() path the test was added to cover in PR #5647.

Worth noting, found that the Node versions that pinned is not what hides this issue, it fails on newer versions as well, the reason CI passes is nyc, its .ts hook loads the fixture as CommonJS. Running the spec directly skips that hook and exposes the bug.

I tested and now it passes now with+without nyc.

@mostafaNazari702

Copy link
Copy Markdown
Contributor Author
bild bild

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi @mostafaNazari702, thanks for the pull request! A scan flagged a concern with it. Could you please take a look?

[pr-task-completion] This PR's body is missing [x] checks on the following tasks from the PR template.

Repositories often provide a set of tasks that pull request authors are expected to complete. Those tasks should be marked as completed with a [x] in the pull request description. Please complete those tasks and mark the checks as [x] completed.

🗺️ This message was posted automatically by OctoGuide: a bot for GitHub repository best practices.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.64%. Comparing base (f2243a6) to head (8a10e1e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6160   +/-   ##
=======================================
  Coverage   82.64%   82.64%           
=======================================
  Files          62       62           
  Lines        4668     4668           
  Branches     1003     1034   +31     
=======================================
  Hits         3858     3858           
  Misses        810      810           

☔ View full report in Codecov by Harness.
📢 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.

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.

🛠️ Repo: esm-utils test fails on newer Node 24 because a .ts fixture uses require()

1 participant