In FindAllBy and FindAll query helper types: spread Arguments to support no arguments#1230
Open
dturcotte wants to merge 1 commit intotesting-library:mainfrom
Open
In FindAllBy and FindAll query helper types: spread Arguments to support no arguments#1230dturcotte wants to merge 1 commit intotesting-library:mainfrom
dturcotte wants to merge 1 commit intotesting-library:mainfrom
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 0781b30:
|
Codecov Report
@@ Coverage Diff @@
## main #1230 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 24 24
Lines 1042 1042
Branches 351 347 -4
=========================================
Hits 1042 1042
Flags with carried forward coverage won't be shown. Click here to find out more. 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
astorije
approved these changes
Jul 7, 2023
astorije
left a comment
There was a problem hiding this comment.
@eps1lon, @MatanBobi, @timdeschryver, what do you all think about this? 🙏
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What: Custom queries returned by
buildQuerieswhose implementation required no arguments (besidescontainer) still required one argument forfind*andfindAll*even when used onscreenorwithin.Without the

query-helpers.d.tschanges introduced by this PR, see these TS errors in the updatedtype-tests:Why: There was a lot of great work done on these types here and here, I want to build on that to solve this one additional edge case.
For context on why we have queries with no arguments: we have a library with UI components that other teams consume. We also provide a few custom queries for things we don't want the consumers to worry about. For example: We provide a
DataGridcomponent with the option to select rows. It's possible to find the input to select a row using base testing-library features but consumers shouldn't need to know how the sausage is made, for their convenience we want them to be able to simply say:await userEvent.click(within(row).getGridRowSelectionInput())This works, however I noticed that for the
findandfindAllqueries the first arg is always required. It would end up looking like this to make TS happy:await within(row).findGridRowSelectionInput(undefined)How: Spreading
ArgumentsinFindByandFindAllBytypes would fix this; the resulting queries should better match the types passed intobuildQueries. If there are no arguments aftercontainerthen the resulting query would have two:containerandwaitForOptions. This would also allow for more than two args if needed. Lastly, this doesn't change the fact thatcontaineris required:Checklist:
docs site N/A