Skip to content
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

Merged
merged 6 commits into from
May 4, 2022
Merged

Conversation

saseungmin
Copy link
Member

@saseungmin saseungmin commented Apr 4, 2022

해결해야할 사항

image

image

-  Update dependencies emotion, remirror, next, react, react-hook-form, react-query, testing-library, jest, cypress
@saseungmin saseungmin added the 🛠 Setting Install Dependencies & Setting for project label Apr 4, 2022
@vercel
Copy link

vercel bot commented Apr 4, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/jennie-harang/conners/6odppMS712BrTAuduMsU1FnKicr4
✅ Preview: https://conners-git-setting-issue-348-jennie-harang.vercel.app

@saseungmin saseungmin linked an issue Apr 4, 2022 that may be closed by this pull request
4 tasks
@codecov
Copy link

codecov bot commented Apr 4, 2022

Codecov Report

Merging #349 (bc5e8d6) into main (0f2e3a3) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #349   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          174       174           
  Lines         2914      2914           
  Branches       301       301           
=========================================
  Hits          2914      2914           
Impacted Files Coverage Δ
src/components/auth/SignUpForm.tsx 100.00% <100.00%> (ø)
src/components/common/SubHeader.tsx 100.00% <100.00%> (ø)
src/components/detail/ApplyFormModal.tsx 100.00% <100.00%> (ø)
src/containers/home/StatusBarContainer.tsx 100.00% <100.00%> (ø)
src/test/InjectTestingRecoilState.tsx 100.00% <100.00%> (ø)
src/test/ReactQueryWrapper.tsx 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f2e3a3...bc5e8d6. Read the comment docs.

saseungmin added 2 commits May 3, 2022 23:07
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 설정 변경
@vercel
Copy link

vercel bot commented May 3, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
conners ✅ Ready (Inspect) Visit Preview May 4, 2022 at 4:37PM (UTC)

@@ -22,7 +22,13 @@ const customJestConfig = {
coveragePathIgnorePatterns: [
'<rootDir>/src/components/detail/RecruitCompleteCanvasConfetti.tsx',
],
testEnvironment: 'jsdom',
moduleDirectories: ['node_modules', '<rootDir>/'],
testEnvironment: 'jest-environment-jsdom',
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +30 to +33
...await createJestConfig(customJestConfig)(),
transformIgnorePatterns: [
'node_modules/(?!(@firebase|nanoid|@hookform)/)',
],
Copy link
Member Author

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';
Copy link
Member Author

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';
Copy link
Member Author

@saseungmin saseungmin May 3, 2022

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([]));
Copy link
Member Author

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로 변경
@saseungmin saseungmin added Bugfix/Function Fix to bug and isn't working Refactor Refactoring for code Testing about test, e2e test Improve/Function 기존 기능에 향상시킬 수 추가적인 기능 labels May 4, 2022
Comment on lines +9 to +26
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;
},
}));
Copy link
Member Author

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",
Copy link
Member Author

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이하였기때문.

@saseungmin saseungmin mentioned this pull request May 4, 2022
4 tasks
@saseungmin
Copy link
Member Author

👉 해당 PR은 squash merge가 아니라 모든 commit 내용을 기록하기 위해서 기본 merge로 진행 👈

@saseungmin saseungmin merged commit d9dc017 into main May 4, 2022
@saseungmin saseungmin deleted the setting/issue-348 branch May 4, 2022 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix/Function Fix to bug and isn't working Improve/Function 기존 기능에 향상시킬 수 추가적인 기능 Refactor Refactoring for code 🛠 Setting Install Dependencies & Setting for project Testing about test, e2e test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

React 18 마이그레이션
1 participant