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

Unknown option "jestWebpackResolver"

Open lucasriondel opened this issue 6 years ago • 6 comments

First of all, thanks for your package. It works like a charm.

But I have a small issue... I have to set a path to my webpack config, or else I have the following message:

Webpack Resolver couldn't find any configuration. Tries to resolve ./webpack.config.js
Webpack Resolver Error: Not able to find any valid webpack configuration
● Validation Error:

  Module <rootDir>/node_modules/babel-jest in the transform option was not found.
         <rootDir> is: C:\Users\LucasRIONDEL\dev\fmu\frontend

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html

So I did like you said in the Readme, and i added the following to my jest.config.json:

  "jestWebpackResolver": {
    "webpackConfig": "./webpack/webpack.common.js"
  }

Which works. But when i launch jest, i have the following message:

● Validation Warning:

  Unknown option "jestWebpackResolver" with value {"webpackConfig": "./webpack/webpack.common.js"} was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html

Webpack Resolver using: ./webpack/webpack.common.js

Which is really weird. Do you have any idea why ?

(using jest ^23.6.0)

lucasriondel avatar Feb 06 '19 13:02 lucasriondel

Seeing the same issue with:

"jest": "^24.7.1",
"jest-webpack-resolver": "^0.3.0",

samparnell avatar May 16 '19 01:05 samparnell

Seems the easiest workaround here is to just rename/move your webpack config to the default or just create a symlink or something :)

That works but in turn has an annoying side effect where Webpack Resolver couldn't find any configuration. Tries to resolve ./webpack.config.js gets logged every time...

alexweber avatar Apr 08 '20 16:04 alexweber

what do you mean when you say move to default. can you tell more ?

Shripad03 avatar Aug 02 '20 07:08 Shripad03

I was able to resolve the Validation Warning: Unknown option "jestWebpackResolver" by moving this value from jest.config.js :

"jestWebpackResolver": {
  "silent": true,
  "webpackConfig": "webpack.config.js"   
}

to package.json.

Leaving these values in my jest.config.js:

module.exports = {
  moduleNameMapper: {
    "\\.css$": "<rootDir>/__mocks__/styleMock.js"
  },
  resolver: "jest-webpack-resolver",
  setupFilesAfterEnv: ['<rootDir>/src/setUpTests.js']
}

using:

"jest": "^26.4.2",
"jest-webpack-resolver": "^0.3.0",

patrick-s-young avatar Sep 14 '20 22:09 patrick-s-young

@Shripad03 I meant just webpack.config.js as a workaround but the solution provided by @patrick-s-young works perfectly!

alexweber avatar Sep 14 '20 22:09 alexweber

@alexweber the Jest issue came up during a React boilerplate project. I wanted to support directory aliasing across Webpack / TypeScript / ESLint / and Jest: https://github.com/patrick-s-young/react-ts-eslint-webpack-babel

If you have any feedback for improving it, please let me know.

patrick-s-young avatar Sep 16 '20 19:09 patrick-s-young