Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There are a few ways to avoid Jest from hooking the Node module loader:

  1. Use the --no-require-extensions flag when running Jest. This will prevent Jest from hooking into the require function and modify how modules are loaded.

  2. Define the NODE_OPTIONS environment variable with the --no-icu flag. This will disable the use of the International Components for Unicode (ICU) library, which Jest relies on for module loading.

  3. Use a separate configuration file for Jest and set the "moduleLoader" option to "node". This will use the default Node.js module loader instead of Jest's custom loader.

  4. If using TypeScript, add the "isolatedModules" option to the tsconfig.json file. This will prevent Jest from transforming module imports into custom imports.