JavaScript & TypeScript / Quiz
ESM vs CJS: The Interop Minefield
Unexpected token 'export', transformIgnorePatterns surgery, __dirname's disappearance, and the dual-package hazard. The errors every JS tester must decode on sight.
- Difficulty
- Hard
- Format
- Quiz
- Points
- 200
- Estimate
- 11 min
// MISSION BRIEF
Your Mission
JavaScript has two module systems, and your test runner stands exactly where they collide. The error messages are cryptic, the fixes are configuration, and guessing wrong burns afternoons.
This quiz makes you fluent in the collision zone: why node_modules breaks Jest, what the ignore-pattern regex actually means, ESM-mode Jest, missing __dirname, and packages that ship both formats.
Speed bonus active.
// FIRST CONTACT
Battle teaser
Jest fails inside node_modules/ky with: SyntaxError: Unexpected token 'export'. The app itself builds and runs fine. Root cause:
- Aky ships only ESM; Jest executes CommonJS and by default does NOT transform anything under node_modules, so the raw export statement reaches a CJS interpreter
- BThe test file forgot 'use strict'
- CJest cannot import any third-party HTTP clients
- DThe package is corrupted and needs reinstalling
// SKILL TAGS