jest-css-modules-processor
You can use this module to realize import
/ require
.css
file when you run jest
.
And this module also support localIdentName
😎!
Inspired by css-modules-require-hook and jest-css-modules-transform.
Install
yarn add jest-css-modules-processor --dev
Usage
Just add transform field for your jest config.
{
"jest": {
"transform": {
".+\\.(css)$": "@mtfe/jest-css-modules-processor",
"^.+\\.jsx?$": "babel-jest"
},
}
}
Config
You should add jestCSSProcessor
field in your package.json
.
{
"jestCSSProcessor": {
"generateScopedName": "[name]__[local]___[hash:base64:5]"
}
}
Usually, you just need to set the generateScopedName
option. And it should same as localIndentName
value which you setted in the webpack.config.js