I've been trying to set up a testing environment for my React project and I had a problem with Unexpected token when importing the CSS file. i added the moduleNameMapper to the package.json to fix it and now i'm facing this issue. Does anyone know what can i do to fix this?
> [email protected] test C:\Users\admin\Documents\myApp > jest FAIL _tests_\Home.test.js ● Test suite failed to run Configuration error: Could not locate module react-datepicker/dist/react-datepicker-cssmodules.css (mapped as identity-obj-proxy) Please check: "moduleNameMapper": { "/^.+\.(css|less)$/": "identity-obj-proxy" }, "resolver": undefined Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: 1.894s Ran all test suites. npm ERR! Test failed. See above for more details.
jest portion of package.json
"jest": { "transform": { "^.+\\.jsx?$": "babel-jest" }, "moduleNameMapper": { "\\.(s?css|less)$": "identity-obj-proxy" } },
make sure you have identity-obj-proxy in your devDependencies
"devDependencies": { "identity-obj-proxy": "^3.0.0", ... }
if not, run
npm install --save-dev identity-obj-proxy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With