justinsisley / Jest-CSS-Modules

A Jest script processor that prevents CSS module parse errors.

Home Page:https://www.npmjs.com/package/jest-css-modules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Note: As of v2.0.0, this library is simply implementing identity-obj-proxy. The Jest documentation provides more details on using identity-obj-proxy to solve this problem directly, and I recommend that you use that library instead of this one.

Jest CSS Modules

A Jest script processor that prevents CSS module parse errors.

Installation

npm install -D jest-css-modules

Update your package.json file's jest configuration:

{
  "jest": {
    "moduleNameMapper": {
      "\\.(css|less|scss|sss|styl)$": "<rootDir>/node_modules/jest-css-modules"
    }
  }
}

Now, imports such as import styles from './MyModule.css'; will pass through Jest without causing any pain.

Supports .css, .less, .scss, .sss, and .styl extensions.

Note: If you continue to experience CSS module parsing errors after installing and configuring this library, try running jest with the --no-cache flag. Read the Jest documentation on caching for more details.

About

A Jest script processor that prevents CSS module parse errors.

https://www.npmjs.com/package/jest-css-modules


Languages

Language:JavaScript 67.5%Language:HCL 19.8%Language:CSS 12.7%