From 013b31594bd80f58a2ed3353420d878a16d72808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=99=A9=EC=A4=80=EC=8A=B9?= <78203399+turtle601@users.noreply.github.com> Date: Wed, 26 Jul 2023 14:30:44 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20react=20testing=20library=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20=EC=8B=9C=20=EC=97=90=EB=9F=AC=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20import=20=EC=8B=9C=20=EC=97=90=EB=9F=AC=20=EB=B0=9C?= =?UTF-8?q?=EC=83=9D=20(#155)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * infra: 이슈 템플릿 & PR 템플릿 작성 (#86) * infra: 이슈 템플릿 작성 (#84) * infra: PR 템플릿 작성 (#84) * fix: jest svg, png 관련 컴포넌트 발생 에러 해결 (#154) --------- Co-authored-by: Donghun Shin --- frontend/.eslintrc | 2 +- frontend/fileTransformer.js | 10 ++++++++++ frontend/jest.config.js | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 frontend/fileTransformer.js diff --git a/frontend/.eslintrc b/frontend/.eslintrc index cdd1bcffc..b1ccc95c6 100644 --- a/frontend/.eslintrc +++ b/frontend/.eslintrc @@ -29,7 +29,7 @@ "version": "detect" } }, - "ignorePatterns": ["build", "dist", "public", "webpack.**.js", "mocks"], + "ignorePatterns": ["build", "dist", "public", "webpack.**.js", "mocks", "fileTransformer.js"], "rules": { "no-console": "warn", "react/react-in-jsx-scope": "off", diff --git a/frontend/fileTransformer.js b/frontend/fileTransformer.js new file mode 100644 index 000000000..6ac5c63ea --- /dev/null +++ b/frontend/fileTransformer.js @@ -0,0 +1,10 @@ +// fileTransformer.js +const path = require('path'); + +module.exports = { + process(sourceText, sourcePath, options) { + return { + code: `module.exports = ${JSON.stringify(path.basename(sourcePath))};`, + }; + }, +}; diff --git a/frontend/jest.config.js b/frontend/jest.config.js index 2ea4e3bdd..c9f02b6e3 100644 --- a/frontend/jest.config.js +++ b/frontend/jest.config.js @@ -5,5 +5,10 @@ module.exports = { setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'], transform: { '^.+\\.[tj]sx?$': 'babel-jest', + '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': + '/fileTransformer.js', + }, + moduleNameMapper: { + '^\\~/(.*)$': '/src/$1', }, };