Skip to content

Commit

Permalink
fix: react testing library 사용 시 에러 이미지 import 시 에러 발생 (#155)
Browse files Browse the repository at this point in the history
* infra: 이슈 템플릿 & PR 템플릿 작성 (#86)

* infra: 이슈 템플릿 작성 (#84)

* infra: PR 템플릿 작성 (#84)

* fix: jest svg, png 관련 컴포넌트 발생 에러 해결 (#154)

---------

Co-authored-by: Donghun Shin <[email protected]>
  • Loading branch information
turtle601 and shin-mallang authored Jul 26, 2023
1 parent 9abbbc5 commit 013b315
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions frontend/fileTransformer.js
Original file line number Diff line number Diff line change
@@ -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))};`,
};
},
};
5 changes: 5 additions & 0 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)$':
'<rootDir>/fileTransformer.js',
},
moduleNameMapper: {
'^\\~/(.*)$': '<rootDir>/src/$1',
},
};

0 comments on commit 013b315

Please sign in to comment.