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

Rtl upgrade #218

Merged
merged 7 commits into from
Nov 24, 2023
Merged

Rtl upgrade #218

merged 7 commits into from
Nov 24, 2023

Conversation

AlexanderKaran
Copy link
Collaborator

  • Upgraded all the tests from enzyme to react testing library to make upgrading to React 18 easier
  • Updated every test to RTL
  • Moved towards more testing patterns supported by RTL

@@ -90,8 +90,8 @@
"@codeshift/test-utils": "^0.3.0",
"@codeshift/utils": "^0.2.0",
"@testing-library/jest-dom": "^5.7.0",
"@testing-library/react": "^10.0.4",
"@types/enzyme": "^3.10.5",
"@testing-library/react": "^10.4.9",

Choose a reason for hiding this comment

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

nit: are we able to upgrade to 14.0.0 (or whatever newest version is without anything breaking? Wonder if we can get best of both worlds ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tried to install the latest version; however it throws an error due to React16 being in the dependent tree

npm install --save-dev @testing-library/[email protected]
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   dev react@"^16.10.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^18.0.0" from @testing-library/[email protected]
npm ERR! node_modules/@testing-library/react
npm ERR!   dev @testing-library/react@"14.1.2" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/akaran/.npm/_logs/2023-11-22T02_25_00_700Z-eresolve-report.txt

Copy link

@SpanishPear SpanishPear Nov 24, 2023

Choose a reason for hiding this comment

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

ah makes sense, RTL v14 is dependent on. react v18

@SpanishPear
Copy link

Looks good! I'll ping someone else to approve but ✅ from me (some nits, but they are nice to haves, not blocking)

SpanishPear
SpanishPear previously approved these changes Nov 21, 2023
@AlexanderKaran
Copy link
Collaborator Author

Looks good! I'll ping someone else to approve but ✅ from me (some nits, but they are nice to haves, not blocking)

Thanks for the review will fix up the comments you mentioned today

@@ -548,12 +548,12 @@ describe('RouterStore', () => {
const RouteName = () => <>{useRouteName()}</>;

const route = {
component: () => null,
component: () => <p>home</p>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any particular reason why this was changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The approach to testing is very different in RTL vs enzyme. The biggest being "test from the perspective of a user". I had to change the test to work by checking for what was rendered.

@@ -567,7 +567,7 @@ describe('RouterStore', () => {
expect.objectContaining({ route }),
undefined
);
expect(wrapper.html()).toEqual('home');
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder why was html==='home'? I thought component: () => null, should render null

Copy link
Collaborator Author

@AlexanderKaran AlexanderKaran Nov 22, 2023

Choose a reason for hiding this comment

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

I am not sure about the old tests, but in the new one, I am rendering something with the text home to ensure things are correctly rendered.

Copy link

@SpanishPear SpanishPear left a comment

Choose a reason for hiding this comment

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

nice!

@MonicaOlejniczak if you're happy with it - are you able to merge? I don't have perms 😮‍💨

@MonicaOlejniczak MonicaOlejniczak merged commit b0e55fa into atlassian-labs:master Nov 24, 2023
4 checks passed
@AlexanderKaran AlexanderKaran deleted the rtl-upgrade branch November 24, 2023 02:19
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.

6 participants