Frontend/Error
[오류해결] VSCode - Cannot find name 'test'. Do you need to install type definitions for a test runner?
[오류해결] VSCode - Cannot find name 'test'. Do you need to install type definitions for a test runner?
2024.03.11오류 발생 VSCode에서 Typescript로 작성된 테스트코드에 붉은 밑줄이 그어지며 오류 메시지가 나타났다. 참고로 yarn test 같은 테스트 실행 명령어로 동작은 잘 되는 상태였다. 오류 상세 Cannot find name 'test'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.ts(2582) 원인 분석 VSCode에서 Jest의 타입을 불러오지 못해서 발생한 오류였다. 해결 방법 해결방법은 tsconfig.json 파일에 아래와 같이 "@types/jest"를 추가한다. 물론 tsconfig..
[오류해결] ESLint 'test' is not defined. no-undef
[오류해결] ESLint 'test' is not defined. no-undef
2024.03.11오류 발생 테스트코드를 작성했는데 VSCode에서 아래의 오류 상세처럼 'test' is not defined.라는 eslint의 no-undef유형의 오류가 발생했다. 오류 상세 원인 분석 ESLint의 설정 파일에 Jest와 관련된 설정들이 추가되어있지 않아서 발생한 문제이다. 해결 방법 .eslintrc.cjs파일에 다음과 같이 "jest/globals"설정 값을 추가하면 오류메시지가 더 이상 나타나지 않는다. module.exports = { ...생략... env: { ..., "jest/globals": true, }, ...생략... } 참고 자료 https://stackoverflow.com/questions/55807824/describe-is-not-defined-when..
[오류해결] Error [ERR_REQUIRE_ESM]: require() of ES Module ~ node_modules/cliui/build/index.cjs not supported.
[오류해결] Error [ERR_REQUIRE_ESM]: require() of ES Module ~ node_modules/cliui/build/index.cjs not supported.
2024.03.11오류 발생 yarn test 명령어로 테스트 코드를 실행하려는데 아래와 같이 오류가 발생했다. yarn v1.22.21 node 20.10.0 오류 상세 yarn test yarn run v1.22.21 $ jest Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/iksflow/${PROJECT_ROOT}/node_modules/string-width/index.js from /Users/iksflow/${PROJECT_ROOT}/node_modules/cliui/build/index.cjs not supported. Instead change the require of index.js in /Users/iksflow/${PROJECT_ROOT}/node..
[오류해결] 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.
[오류해결] 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.
2024.03.10오류 발생 VSCode에서 Typecript + React 환경으로 개발을 하던 중 에디터에 React 컴포넌트에 붉은줄이 마구 생기면서 아래와 같은 오류가 발생했다. 딱히 건드린 코드가 없는데 갑자기 발생한 오류라 당황스러웠다. 오류 상세 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. 원인 분석 React 16에서 React 17로 넘어가면서 JSX Transformation 방식이 변했는데 이로 인해 발생하는 문제라고 한다. React 17에서 Transformation과 관련해 변경된 부분은 2가지이다. 첫 번째는 기존에는 React 컴포넌트 코드에 i..