-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: Support React 19 and remove Jest reliance in test utils #7686
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a32b16e
attempt to get rid of jest calls in menu util
LFDanLu e326a35
update RSP testing docs to directly mention mocks that maybe needed
LFDanLu 9481673
bump versions of RTL to 16
LFDanLu f625818
use alternative to calling jest run timers in menu option selection
LFDanLu 69d289f
fixing types and properly testing long press
LFDanLu 366c1f8
fix lint
LFDanLu 5a502b8
Merge branch 'main' of github.com:adobe/react-spectrum into test_util…
LFDanLu 8f55260
revert to pre testing library bump for clean slate
LFDanLu 93cbb33
fix build and another submenu edge case
LFDanLu 5207639
fix react 16 bug
LFDanLu 14452d8
update return type of advanceTimer and docs copy
LFDanLu dd52a74
move some general fixes from selectionMode="replace" branch here
LFDanLu 5d8740c
get rid of unneeded async
LFDanLu 24805ce
getting rid of extraneous dep
LFDanLu 1107831
Merge branch 'main' of github.com:adobe/react-spectrum into test_util…
LFDanLu 82797f6
fix lint
LFDanLu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -423,7 +423,7 @@ import {theme} from '@react-spectrum/theme-default'; | |
| import {User} from '@react-spectrum/test-utils'; | ||
|
|
||
| let testUtilUser = new User({interactionType: 'mouse'}); | ||
| // ... | ||
| // Other setup, be sure to check out the suggested mocks mentioned above in https://react-spectrum.adobe.com/react-spectrum/ListBox.html#testing | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hopefully makes it a little more clear that additional setup might be needed for RSP components in general |
||
|
|
||
| it('ListBox can select an option via keyboard', async function () { | ||
| // Render your test component/app and initialize the listbox tester | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The chain of waitFors below is a bit gross, but allows us to get rid of any assumptions of how long it will take the menu to close/transition out. Open to any alternatives
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 think it might be better to pass in a function which could advance the timers by whatever amount.
I'm not sure how waitFor works in a mocked timer situation since technically it does polling which is based on timers.... at least, in the non-mocked timers case. You may want to have a look at the source for waitFor.
The alternative is to do something like test-library does with their userSetup({delay: null/50/100/whatever})
Uh oh!
There was an error while loading. Please reload this page.
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.
selectOption({option, timerForClose: () => act(() => jest.runAllTimers())})happy to workshop the name
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.
waitForadvances fake timers if it detects them via: https://github.com/testing-library/dom-testing-library/blob/a86c54ccda5242ad8dfc1c70d31980bdbf96af7f/src/wait-for.js#L75-L82 and does polling. The only thing I'm a bit wary about with regards to making the user pass thetimerForCloseis twofold:waitForunder the hood reduces the burden on the user to get the timing right.timerForClosemay open the need/possibility of adding the same kind of api to many of the other interaction calls in the utils. Perhaps it would be best for the user to perform their own polling after callingselectOptioninstead? Perhaps we could expect that they should await focus to return to a specific element outside of the util insteadThere 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.
Ah, didn't know it would advance fakeTimers, that's great, then I think this is fine