Skip to content

Instantly share code, notes, and snippets.

@tpluscode
Created February 27, 2026 18:36
Show Gist options
  • Select an option

  • Save tpluscode/f5f1248509068afa033797bb51bd7dea to your computer and use it in GitHub Desktop.

Select an option

Save tpluscode/f5f1248509068afa033797bb51bd7dea to your computer and use it in GitHub Desktop.
Mocha 11 + tsx = ?
node_modules/
  1. npm i
  2. npm t
  3. npm i mocha@^11
  4. npm t

First run, using mocha 10, works.

Second run will fail because somehow the modules are not loaded correctly.

The "only" difference is mocha. Why is tsx no longer working corectly

import * as assert from "node:assert";
import env from "@zazuko/env";
import { describe, it } from "mocha";
describe('using tsx', () => {
it('should load module correctly', () => {
assert.equal(env.ns.schema.Person.value, "http://schema.org/Person")
})
});
{
"name": "mocha-tsx",
"type": "module",
"scripts": {
"test": "mocha index.test.ts"
},
"dependencies": {
"@zazuko/env": "^3.0.1",
"mocha": "^10",
"tsx": "^4.21.0",
"typescript": "^5.9.3"
},
"mocha": {
"require": "tsx"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment