-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Setting] React 18로 마이그레이션하라 #349
Conversation
- Update dependencies emotion, remirror, next, react, react-hook-form, react-query, testing-library, jest, cypress
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/jennie-harang/conners/6odppMS712BrTAuduMsU1FnKicr4 |
Codecov Report
@@ Coverage Diff @@
## main #349 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 174 174
Lines 2914 2914
Branches 301 301
=========================================
Hits 2914 2914
Continue to review full report at Codecov.
|
1. react-testing-library/hooks는 react 18미지원 => react-testing-library/react로 사용 - 그에 따라 react-testing-library/react-hooks는 삭제 2. 전체 dependencies update 3. React 18 마이그레이션 후 remirror 에러를 수정 4. jest 설정 변경
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
- 타입 지정
@@ -22,7 +22,13 @@ const customJestConfig = { | |||
coveragePathIgnorePatterns: [ | |||
'<rootDir>/src/components/detail/RecruitCompleteCanvasConfetti.tsx', | |||
], | |||
testEnvironment: 'jsdom', | |||
moduleDirectories: ['node_modules', '<rootDir>/'], | |||
testEnvironment: 'jest-environment-jsdom', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...await createJestConfig(customJestConfig)(), | ||
transformIgnorePatterns: [ | ||
'node_modules/(?!(@firebase|nanoid|@hookform)/)', | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node_modules ignore transform Patterns
vercel/next.js#36077
import { yupResolver } from '@hookform/resolvers/yup/dist/yup'; | ||
import { yupResolver } from '@hookform/resolvers/yup'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
버전업되면서 경로가 변경됨
https://github.com/react-hook-form/resolvers#yup
import React, { ReactChild, ReactElement } from 'react'; | ||
import React, { PropsWithChildren, ReactElement } from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await waitFor(() => result.current.isSuccess); | ||
|
||
expect(result.current.data).toEqual([]); | ||
await waitFor(() => expect(result.current.data).toEqual([])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- react-hooks console.error 수정 - react-test-renderer dependency 추가 (해당 버전에 맞는 peer dependency 사용)
- 컴포넌트 관련 테스트에서 react-query hooks로 인해 act console.error 발생 - react-query hooks를 jest mocking - dynamic import 전역 mocking 추가 - 추후 msw로 변경
jest.mock('next/dynamic', () => ({ | ||
__esModule: true, | ||
default: (...props) => { | ||
const dynamicModule = jest.requireActual('next/dynamic'); | ||
const dynamicActualComp = dynamicModule.default; | ||
const RequiredComponent = dynamicActualComp(props[0]); | ||
|
||
if (RequiredComponent.preload) { | ||
RequiredComponent.preload(); | ||
|
||
return RequiredComponent; | ||
} | ||
|
||
RequiredComponent.render.preload(); | ||
|
||
return RequiredComponent; | ||
}, | ||
})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"jest-plugin-context": "^2.9.0", | ||
"lint-staged": "^12.1.2", | ||
"node-mocks-http": "^1.11.0", | ||
"react-test-renderer": "^18.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@testing-library/react-hooks에 react-test-renderer peer dependency로 적용되어있음.
따라서 해당 버전에 따라서 @testing-library/react-hooks가 동작하는 방식이 다름. render.dom console.error가 발생했던 원인은 peer dependency의 react-test-renderer가 버전이 react 18이하였기때문.
👉 해당 PR은 squash merge가 아니라 모든 commit 내용을 기록하기 위해서 기본 merge로 진행 👈 |
해결해야할 사항
After migration to React 18, EmojiExtension encounters an error. remirror/remirror#1580
renderHook
testing-library/react-testing-library#9916bce4ec
(#349) 이 커밋에서 해결bc5e8d6
(#349) 이 커밋에서 해결