Jest: Ignore CSS files while running tests
To ensure Jest ignores CSS files when running tests, simply follow the steps below:
- Install a module:
`identity-obj-proxy`
npm install -D
identity-obj-proxy
2. Update your jest config(jest.config.json)
{
"jest":{
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/__mocks__/fileMock.js",
"\\.(css|less|scss|sass)$": "identity-obj-proxy"
},
}
}
Now run your tests again. You should not see failures due to CSS files anymore.