Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justinsisley/jest-css-modules
A Jest script processor that prevents CSS module parse errors.
https://github.com/justinsisley/jest-css-modules
css-modules jest testing webpack
Last synced: 8 days ago
JSON representation
A Jest script processor that prevents CSS module parse errors.
- Host: GitHub
- URL: https://github.com/justinsisley/jest-css-modules
- Owner: justinsisley
- Created: 2015-10-10T02:03:27.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T18:52:11.000Z (almost 2 years ago)
- Last Synced: 2024-10-30T21:05:57.771Z (8 days ago)
- Topics: css-modules, jest, testing, webpack
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/jest-css-modules
- Size: 337 KB
- Stars: 75
- Watchers: 1
- Forks: 16
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
> Note: As of v2.0.0, this library is simply implementing [identity-obj-proxy](https://github.com/keyz/identity-obj-proxy).
> The [Jest documentation](https://jestjs.io/docs/en/webpack.html#mocking-css-modules) 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](https://facebook.github.io/jest/) [script processor](https://facebook.github.io/jest/docs/en/configuration.html#transform-object-string-string) that prevents [CSS module](https://github.com/css-modules/css-modules) parse errors.## Installation
```shell
npm install -D jest-css-modules
```Update your package.json file's `jest` configuration:
```json
{
"jest": {
"moduleNameMapper": {
"\\.(css|less|scss|sss|styl)$": "/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](https://jestjs.io/docs/en/cli#cache) for more details.