Skip to content

Comments

vite + tsconfig alias 경로 설정으로 인한 jest.config.js 경로 설정 관련 에러 관련 로직 공유#123

Draft
park-moen wants to merge 1 commit intodevfrom
chore/test-config
Draft

vite + tsconfig alias 경로 설정으로 인한 jest.config.js 경로 설정 관련 에러 관련 로직 공유#123
park-moen wants to merge 1 commit intodevfrom
chore/test-config

Conversation

@park-moen
Copy link
Collaborator

@park-moen park-moen commented Feb 8, 2023

💡 Linked Issues

📖 bug 발생 원인

  • jest.config.js에서 static assets 관련 확장자를 패턴 매칭으로 찾아서 /mocks/fileMock.js 을 참조하게 만들어줘야 하지만 alias 경로로 static assets file을 찾지 못하는 문제 발생으로 추정
    참고 자료

반영 브랜치

chore/test-config

✅ PR 포인트 & 궁금한 점

  • jest.config.js에서 alias 경로로 설정한 static assets file을 찾을 수 있는 정규 표현식 패턴이 존재하나요?
  • 아니면 제가 지금 생각한 해결책이 잘못된건가요? 그렇다면 어떤 방법으로 문제를 해결 할 수 있을까요?

@park-moen park-moen requested a review from feel5ny February 8, 2023 06:00
@netlify
Copy link

netlify bot commented Feb 8, 2023

Deploy Preview for how-about-it ready!

Name Link
🔨 Latest commit f3bfa31
🔍 Latest deploy log https://app.netlify.com/sites/how-about-it/deploys/63e33a8325b9960008b3116b
😎 Deploy Preview https://deploy-preview-123--how-about-it.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@park-moen park-moen self-assigned this Feb 8, 2023
@park-moen park-moen added the 🐛 Bug 버그 발생 label Feb 8, 2023
Comment on lines +6 to +10
'^@/(.*)$': '<rootDir>/src/$1',

// '\\assets/.(jpg|jpeg|png)$': '<rootDir>/__mocks__/fileMock.js',
'\\.(jpg|jpeg|png)$': '<rootDir>/__mocks__/fileMock.js',
'\\.(css|style|less|sass|scss|svg)$': 'identity-obj-proxy',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'^@/(.*)$': '<rootDir>/src/$1',
// '\\assets/.(jpg|jpeg|png)$': '<rootDir>/__mocks__/fileMock.js',
'\\.(jpg|jpeg|png)$': '<rootDir>/__mocks__/fileMock.js',
'\\.(css|style|less|sass|scss|svg)$': 'identity-obj-proxy',
'@/assets(.*)$': '<rootDir>/__mocks__/fileMock.js',
'^@/(.*)$': '<rootDir>/src/$1',
'\\.(jpg|jpeg|png)$': '<rootDir>/__mocks__/fileMock.js',
'\\.(css|style|less|sass|scss|svg)$': 'identity-obj-proxy',

요렇게 해보시겠어요?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\\assets/.(jpg|jpeg|png)$

\\assets 여기서부터 찾지 못했을거에요 루트 directory를 지정해주지 않아서요-!
루트를 지정해주되, '^@/(.*)$': '/src/$1', 보다 작은 범위의 조건이라 윗줄에 지정해두어서, fileMock을 참조하게 하면 되는군요~

@park-moen park-moen marked this pull request as draft February 9, 2023 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 Bug 버그 발생

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants