-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
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
Trouble Shooting 모음 #26
Labels
Type: Docs
문서 작업 및 수정
Comments
문제 상황msw 테스트 환경에서 작동불가 원인Mock Service Worker는 브라우저에서 작동하지만, 테스트는 노드 환경에서 작동 해결방안테스트 모드에서는 서버로 가동해줘야함 // mocks/server.ts
import { setupServer } from 'msw/node';
import { handlers } from './handlers';
export const server = setupServer(...handlers);
// App.tsx
import ...
if (process.env.NODE_ENV === 'test') {
(async () => {
const { server } = await import('@/mocks/server');
server.listen();
})();
} else if (IS_MOCK) {
(async () => {
const { worker } = await import('@/mocks/browser');
worker.start();
})();
}
const App = () => {
....
}
// src/setupTest.ts
import '@testing-library/jest-dom';
import { server } from '@/mocks/server';
beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close()); 레퍼런스 |
hyorimcho
assigned tnghgks, Noeyso, raw20, greyHairChooseLife, jhoon9494, jiheon788, hyorimcho and bokjunwoo
Mar 23, 2023
문제 상황
요소들이 다 날라간채 debug 출력 원인
해결방안await를 처리 후
|
문제 상황초기 테스트 환경 세팅 시 문제 발생 원인
해결방안
module.exports = {
reactScriptsVersion: 'react-scripts',
webpack: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
plugins: [new TsconfigPathsPlugin({ configFile: tsConfigPath })],
},
jest: {
configure:{
moduleNameMapper: { // 이부분 추가
"^@/(.*)$": "<rootDir>/src/$1",
},
}
}
};
module.exports = {
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1",
},
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
테스트 과정 중 생긴
문제상황
,원인
,해결방안
,레퍼런스
를 Comment로 남겨주세요🙆♂️🙆♀️The text was updated successfully, but these errors were encountered: