devlog_zz

[오류 해결] Jest Could not locate module FileName.css (mapped as identity-obj-proxy) 본문

Front End/React

[오류 해결] Jest Could not locate module FileName.css (mapped as identity-obj-proxy)

YJ_SW 2022. 12. 11. 19:20
728x90

Next.js기반 프로젝트에 Jest Unit test 환경 구성 후 test 파일 실행 시 오류가 발생했다.

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

FAIL  __tests__/index.test.jsx
  ● Test suite failed to run

    Configuration error:
    
    Could not locate module ../styles/Home.module.css mapped as:
    identity-obj-proxy.
    
    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/^.+\\.module\\.(css|sass|scss)$/": "identity-obj-proxy"
      },
      "resolver": undefined
    }

      1 | import Head from 'next/head'
      2 | import Image from 'next/image'
    > 3 | import styles from '../styles/Home.module.css'
        | ^

해결방법

devDependencies에 identity-obj-proxy가 있는지 확인하고 없다면 아래 명령어 실행

package.json 확인

"devDependencies": {
...
	"identity-obj-proxy": "^3.0.0",
}
npm install --save-dev identity-obj-proxy

 

참고 : https://stackoverflow.com/questions/46107310/jest-could-not-locate-module-filename-css-mapped-as-identity-obj-proxy

728x90
Comments