TEL - 09 : jest - SyntaxError: Invalid or unexpected token
in Study Log on Trial Error Log

Jest
SITUATION :
- React,Typescript, Vite 환경에서 테스트를 작성하고 test를 실행하면 아래 같은 메세지가 뜨면서 테스트가 되지 않음
jest SyntaxError: Invalid or unexpected token
REASON :
- Jest에서 sass라던가 png 라던가 필요없는 파일을 불러와서 일으키는 현상 이라고 한다.
- 테스트를 하거나 렌더링 테스트를 할때 필요없는 파일들을 읽지 않게 해야한다.
SOLUTION :
npm i -D jest-transform-stub설치jest.config.js파일을 열어 다음을 추가 해 주자transform: { '.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub', },- 이게 안된다면?
npm i -D identity-obj-proxy설치moduleNameMapper: { '.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'identity-obj-proxy', },을 추가!