(WIP) Exploration/prototyping of test utils package#4836
(WIP) Exploration/prototyping of test utils package#4836
Conversation
jluyau
left a comment
There was a problem hiding this comment.
i think these utils would definitely make writing tests for rsp components much cleaner. another utility class that would help would be interacting with the current dialog (methods to get elements within the content body as well as pressing the dialog buttons)
| ); | ||
| }; | ||
|
|
||
| beforeAll(function () { |
There was a problem hiding this comment.
this is probably on your radar, but having these mocks and such callable with 1 line of code would be nice too!
There was a problem hiding this comment.
Yep, I've been mulling over whether or not these mocks are too broad. Ideally we would limit what it actually gets applied on, similar to
react-spectrum/packages/@react-aria/overlays/test/useOverlayPosition.test.tsx
Lines 244 to 252 in 1c32cd5
Perhaps we can provide a basic util that does the simple mock and offer a way to override/customize
There was a problem hiding this comment.
Another interesting idea that @devongovett brought up was making our virtualized components render as non-virtualized components when rendered in a test environment specifically. That means we won't have to mock any of this stuff, thus avoid possible mock collisions and assumptions. RSP would still write tests with the virtualized components still being virtualized just to make sure things work as expected
| this.rows = within(this.rowgroups[1]).getAllByRole('row'); | ||
| } | ||
|
|
||
| toggleRowSelection(opts: {index?: number, text?: string, needsLongPress?: boolean}) { |
There was a problem hiding this comment.
one helper function that i think would help (since it's come up a bunch) is a method to select a given cell, though i guess it'd require the column and row indexes or text
There was a problem hiding this comment.
sounds good, we have a util for that that we use internally as well actually haha. I think we can start off with searching for cell text first since that is what a user would look for typically and see about supporting a (x row, y column) alternative maybe.
|
Closing this for now, will incorporate the feedback when work resumes on this portion of the testing util work |
Closes
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project:
RSP