We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jest
Icon
@svgr/webpack
svg
object
SVGR
jest.config.js
jest.cofig.js
// 변경 전 /* eslint-disable-next-line @typescript-eslint/no-var-requires */ const nextJest = require('next/jest'); const createJestConfig = nextJest({ dir: './', }); const customJestConfig = { setupFilesAfterEnv: ['<rootDir>/jest.setup.js'], moduleNameMapper: { '^~/(.*)$': '<rootDir>/src/$1', '\\.svg$': '<rootDir>/__mocks__/svg.js', }, testEnvironment: 'jest-environment-jsdom', testPathIgnorePatterns: ['<rootDir>/src/__tests__/utils/*'], }; module.exports = createJestConfig(customJestConfig);
// 변경 후 /* eslint-disable @typescript-eslint/no-var-requires */ const nextJest = require('next/jest'); const createJestConfig = nextJest({ dir: './', }); const jestConfig = async () => { const nextJestConfig = await createJestConfig()(); return { ...nextJestConfig, setupFilesAfterEnv: ['<rootDir>/jest.setup.js'], testEnvironment: 'jest-environment-jsdom', moduleNameMapper: { '^~/(.*)$': '<rootDir>/src/$1', '\\.svg$': '<rootDir>/__mocks__/svg.js', }, testPathIgnorePatterns: ['<rootDir>/src/__tests__/utils/*'], }; }; module.exports = jestConfig;
The text was updated successfully, but these errors were encountered:
L2HYUNN
No branches or pull requests
📣 이슈 내용
jest
에서Icon
컴포넌트를 사용하지 못하는 문제가 있습니다.✏️ 상세 설명
jest
에서Icon
컴포넌트를 사용하지 못하는 문제가 있습니다.Icon
컴포넌트를 랜더하지 못하고 있습니다.jest
에서 svg를 컴포넌트로 사용하기 위해@svgr/webpack
를 사용할 때svg
가 기본적으로 매핑되는 방식이 이미지object
형태이기 때문에 발생하는 문제로 보입니다.시도한 방법
1.
SVGR
에서 제공하는 Jest 설정 추가2. vercel/next.js#42535 참고하여
jest.config.js
수정해결
jest.cofig.js
를 다음과 같이 변경하였습니다.🧑🏻💻 할 일
📁 참고 자료
The text was updated successfully, but these errors were encountered: