Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jest Could not locate module FileName.css (mapped as identity-obj-proxy)

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"     }   }, 
like image 910
Eric Avatar asked Sep 08 '17 01:09

Eric


Video Answer


1 Answers

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 
like image 106
Yusufali2205 Avatar answered Sep 20 '22 15:09

Yusufali2205