Book: TypeScript in Production — Tooling, Build, and Library Authoring Across Runtimes Also by me: The TypeScript Library — the 5-book collection My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub You open a file called payments.test.ts . The first thing you need to do is replace one function on a module the file under test imports. In CJS this was a one-liner: reassign the property on the require d object and move on. In ESM that line throws. Module namespace exports are read-only. You cannot patch them. You cannot reassign them. The runtime will let you compile, then slap your wrist at the moment the test tries to write. So you reach for the runner. And here the answer depends on which runner you reached for. Vitest has vi.mock . Bun has mock.module . Node 24 has mock.module on the built-in node:test runner, behind no flag now, and a different shape again.…