jest-webpack-alias icon indicating copy to clipboard operation
jest-webpack-alias copied to clipboard

Error when webpack.config.js exports a function

Open dcalhoun opened this issue 7 years ago • 2 comments

When webpack.config.js exports a function, jest-webpack-alias throws the following error:

  ● Test suite failed to run

    Missing setting "resolve.modules" (webpack v2) or "resolve.root" (webpack v1) in /Users/davidcalhoun/Sites/web/gn-web/webpack.config.js
      
      at Object.read (node_modules/jest-webpack-alias/lib/webpackInfo.js:38:11)
      at ensureWebpackInfo (node_modules/jest-webpack-alias/lib/preprocessor.js:26:33)
      at Object.process (node_modules/jest-webpack-alias/lib/preprocessor.js:165:3)
      at Object.process (test/preprocessor.js:9:45)

The reason I am attempting to export a function is to setup environment-specific configs utilizing webpack-merge. Is it possible to support exporting a function?

My issues appear to be similar to #15.

dcalhoun avatar Mar 08 '17 19:03 dcalhoun

The main question would be: what arguments, if any, should we pass to the function in order to execute it? The webpack docs seem a bit ambiguous on this point: they pass { env: env } but then have just (env) in the signature, and then never even use the variable they pass in. Once that's settled, it's easy enough to support.

mwolson avatar Mar 08 '17 20:03 mwolson

For posterity's sake, I ended up removing almost all of my Webpack aliases and thus do not need this library to support Jest.

Thank you for considering adding this, but I will no longer need its support. Feel free to close this issue, if you'd like. Thank you for open-sourcing this helpful library! 😄

dcalhoun avatar Apr 11 '17 13:04 dcalhoun