In my webpack config file, I have the following configuration option that resolves all modules to a few common root paths where they might be found:
resolve: {
// you can now require('file') instead of require('file.coffee')
extensions: ['', '.js', '.json', '.coffee'],
// Now you can require('file') instead of require('../../file')
root: [__dirname + '/assets', path.join(__dirname, 'vendor/assets/components')]
},
This allows me to use absolute paths in my require() calls. How would I be able to replicate the same feature with jest? I have looked at the setupEnvScriptFile configuration option. Here are the content of my configuration block and the testSetup.js file:
# package.json
"jest": {
"globals": {
"__DEV__": true
},
"setupEnvScriptFile": "script/testSetup2.js",
"scriptPreprocessor": "script/preprocessor.js",
"testFileExtensions": ["coffee", "js"],
"unmockedModulePathPatterns": ["<rootDir>/node_modules/react"]
}
# testSetup.js
process.env.NODE_PATH = __dirname + "/assets";
This doesn't work for me for whatever reason. What am I doing wrong?