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

chore: migrate to react 18 #582

Merged
merged 5 commits into from
Jul 29, 2024
Merged

chore: migrate to react 18 #582

merged 5 commits into from
Jul 29, 2024

Conversation

shadowusr
Copy link
Member

@shadowusr shadowusr commented Jul 28, 2024

What's done:

  • React 16 -> React 18
  • Enzyme -> @testing-library/react
  • Updated a bunch of other packages
  • Tests are mostly updated to testing-library without major changes, but some tests were refactored here and there. Notably, test/unit/lib/static/components/modals/screenshot-accepter/index.jsx was rewritten from ground up.
  • rc-resize-observer -> @react-hook/resize-observer
  • removed styled-components that were used in just one place

⚠️ You may notice that some tests became less "unit'y" and lean towards integration tests. Here's rationale:

⚠️ Also, some tests have a lot of duplicate setup code. I've spent a while trying to make this better, but in the end it comes to a choice whether a test is self-contained&easily readable or there's no duplication. I chose readability. If you see a concrete way of achieving both, I'd be glad to hear!

Copy link
Member

@KuznetsovRoman KuznetsovRoman left a comment

Choose a reason for hiding this comment

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

Looks like react-testing-library does not give a nice way to query by class name as they don't want us to do it:

Note that using this as an escape hatch to query by class or id is not recommended because they are invisible to the user

If you find yourself using container to query for rendered elements then you should reconsider! The other queries are designed to be more resilient to changes that will be made to the component you're testing

It does not seem to worth fixing these in old tests, though.

.mocharc.js Outdated Show resolved Hide resolved
lib/static/components/state/state-error.jsx Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
test/unit/lib/static/components/bullet.jsx Show resolved Hide resolved
@shadowusr shadowusr merged commit 0bbf550 into master Jul 29, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants