Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown option "jestWebpackResolver" #17

Open
lucasriondel opened this issue Feb 6, 2019 · 6 comments
Open

Unknown option "jestWebpackResolver" #17

lucasriondel opened this issue Feb 6, 2019 · 6 comments

Comments

@lucasriondel
Copy link

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)

@samparnell
Copy link

Seeing the same issue with:

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

@alexweber
Copy link

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...

@Shripad03
Copy link

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

@patrick-s-young
Copy link

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",

@alexweber
Copy link

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

@patrick-s-young
Copy link

patrick-s-young commented Sep 16, 2020

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants