Skip to content

🐛 Bug: mocha 11 with tsx breaks some modules #5774

@tpluscode

Description

@tpluscode

Bug Report Checklist

  • I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
  • I have searched for related issues and issues with the faq label, but none matched my issue.
  • I have 'smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, my usage of Mocha, or Mocha itself.
  • I want to provide a PR to resolve this

Expected

Updating mocha from 10 to 11 should not break tests

Actual

Module from node_modules are loaded incorrectly when using tsx

Minimal, Complete and Verifiable Example

https://gist.github.com/tpluscode/f5f1248509068afa033797bb51bd7dea

Versions

> npx mocha --version
11.7.5
> node_modules/.bin/mocha --version
11.7.5
> node --version
v20.19.4

Same with node 24

Additional Info

No response

Metadata

Metadata

Assignees

Labels

status: in triagea maintainer should (re-)triage (review) this issuetype: buga defect, confirmed by a maintainer

Type

No type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions