jest-alias-module-loader
Jest doesn't really have a simple way of globally replacing certain modules, but I've come up with a couple. Firstly, the hacky and gross way to replace modules is by using a regexp replace in the preprocessor. But let's not do that. Instead, this module extends the default HasteModuleLoader
to allow us to alias some modules at require
time:
// test/aliasedModuleLoader.js var JestAliasModuleLoader = ; moduleexports = ;
To use this, just add a line to your Jest config (eg. in package.json
):