-
Notifications
You must be signed in to change notification settings - Fork 66
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
[BD-46] feat: updates to React 18 #2774
base: master
Are you sure you want to change the base?
[BD-46] feat: updates to React 18 #2774
Conversation
Thanks for the pull request, @PKulkoRaccoonGang! This is currently a draft pull request. When it is ready for our review and all tests are green, click "Ready for Review", or remove "WIP" from the title, as appropriate. |
✅ Deploy Preview for paragon-openedx ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
I was able to get to a point where I think doing that migration is a good next step. Sidenote: it's not clear to me what switching tests to be async has to do with upgrading to react 18. Could you elaborate as to why that's included in this PR? |
@brian-smith-tcril after updating the version of React and testing packages, I noticed that there were problems with the successful execution of tests and a large number of errors in the console. Switching tests to asynchrony and wrapping the necessary elements in |
I figure if we're moving all the tests to async to support RTL 14 we should figure out what patterns we life. I looked into what it would take to get the tests in Using the patterns outlined in https://testing-library.com/docs/dom-testing-library/api-async/#findby-queries and https://testing-library.com/docs/user-event/intro#writing-tests-with-userevent I came up with 119eeb0 In most places it was just a matter of changing
could you provide some examples of these? |
@brian-smith-tcril Thank you! This is an excellent solution that can be actively used in our tests! 💯
Immediately after successfully updating the dependencies, I encountered errors related to incorrect expectations in the tests. For example, this test in the Breadcrumb component will display an error after running:
I tried the option you suggested from the official documentation and it works great |
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.
I'm so glad you got this working! Couple tiny suggestions to ensure we're following the recommended patterns from the docs
Note that, while directly invoking APIs such as userEvent.click() (which will trigger setup internally) is still supported in v14, this option exists to ease the migration from v13 to v14, and for simple tests. We recommend using the methods on the instances returned by userEvent.setup().
const clickHandler = jest.fn(); | ||
render(<Breadcrumb {...baseProps} clickHandler={clickHandler} />); | ||
setup(<Breadcrumb {...baseProps} clickHandler={clickHandler} />); |
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.
setup(<Breadcrumb {...baseProps} clickHandler={clickHandler} />); | |
const { user } = setup(<Breadcrumb {...baseProps} clickHandler={clickHandler} />); |
|
||
const listItems = screen.queryAllByRole('listitem'); | ||
const links = screen.queryAllByRole('link'); | ||
expect(listItems.length).toBe(baseProps.links.length); | ||
|
||
userEvent.click(links[0]); | ||
await userEvent.click(links[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.
await userEvent.click(links[0]); | |
await user.click(links[0]); |
Description
Include a description of your changes here, along with a link to any relevant Jira tickets and/or Github issues.
Deploy Preview
Include a direct link to your changes in this PR's deploy preview here (e.g., a specific component page).
Merge Checklist
example
app?wittjeff
andadamstankiewicz
as reviewers on this PR.Post-merge Checklist