-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Upgrade to FE to use React 18 #54432
Comments
Sample try when just bumping deps: #54686 test failures: https://github.com/getsentry/sentry/actions/runs/5857714436/ TypeError: Cannot read properties of undefined (reading 'current')It seems that ref https://github.com/testing-library/react-hooks-testing-library#a-note-about-react-18-support, it seems that We probably need to swap to An alternative is to swap out all usage of
Unable to find an element with the text: Nested Container - nestedIt seems that
Timed out in waitForElementToBeRemovedSome timeouts, but this might just be a flake, nothing confirmed.
|
I think in TSC we talked about using 18 with the legacy renderer and migrating after to the new react 18 renderer. This will break the migration into easier chunks since we can get both repos to react 18 and the test updates and then migrate to the new renderer (and probably fix tests again). Proposed path:
React Hook test migrationShim
|
it('should throw if none of groupIds, replayIds, transactionNames is provided', () => { | |
const {result} = reactHooks.renderHook(useReplaysCount, { | |
initialProps: { | |
organization, | |
}, | |
}); | |
expect(result.error).toBeTruthy(); | |
}); |
Remove act from hook tests
it stops working in the next version, should be using waitFor probably
https://github.com/getsentry/sentry/blob/master/static/app/views/replays/detail/network/useSortNetwork.spec.tsx#L178-L180
Component test migration
Change RTL jest import
Instead of '@testing-library/jest-dom/extend-expect',
in the jest.config. add import '@testing-library/jest-dom';
to the test setup.
Ignore react 18 warning
in setupFramework.ts add
if (
/Warning: ReactDOM.render is no longer supported in React 18/.test(errorMessage)
) {
return true;
}
Use a regular date mock jest.useFakeTimers().setSystemTime
Some tests are using fake timers to mock the date, this is not how we should be freezing the date since it breaks timeouts etc. We have a date mock library we can switch to.
jest.useFakeTimers().setSystemTime(new Date('2022-08-02')); |
Fix various act errors
@AbhiPrasad covered this. Need to use more await screen.findBy
in tests to silence act warnings that were previously hidden.
fix various waitForElementToBeRemoved
@AbhiPrasad covered this. just swap these for waitFor(() => expect(screen.queryBy()).not.toBeInTheDocument())
or remove
Other things to do
- bump emotion, there's some react 18 type conflicts that are fixed in the latest verison
- Add
children?: React.ReactNode
where necessary - Tons of type fixes like
withSentryRouter
probably needs a return type - type needs to have children added to it
here's where i just kinda mashed a bunch together https://github.com/getsentry/sentry/pull/57987/files
Problem Statement
Investigate
Tasks
https://react.dev/blog/2022/03/29/react-v18
Upgrade guide: https://react.dev/blog/2022/03/08/react-18-upgrade-guide
We'll get:
useTransition
and some other new hooksSolution Brainstorm
To investigate
useSyncExternalStore
Product Area
Unknown
The text was updated successfully, but these errors were encountered: