test: load the mocha-error esm-utils fixture as .cts#6160
test: load the mocha-error esm-utils fixture as .cts#6160mostafaNazari702 wants to merge 1 commit into
Conversation
|
👋 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
Repositories often provide a set of tasks that pull request authors are expected to complete. Those tasks should be marked as completed with a
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|


PR Checklist
status: accepting prsOverview
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.