Skip to content

Add find* queries #44

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 7 commits into from
Aug 18, 2020
Merged

Conversation

umpox
Copy link
Contributor

@umpox umpox commented Aug 17, 2020

Adds all the find* queries from dom-testing-library.

This should be quite useful given the asynchronous nature of E2E tests.

I have also updated the README to remove waitForElement as a known limitation, as it is deprecated in dom-testing-library and the recommended alternative is find* queries or waitFor which should now be supported!.

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

thanks so much for the contribution @umpox!


export interface IScopedQueryUtils extends IScopedQueryMethods {
getQueriesForElement(): IQueryUtils & IScopedQueryUtils
export interface IScopedQueryUtils extends BoundFunctions<IQueryMethods> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure BoundFunctions will work for us if it uses HTMLElement type inferences when we're using puppeteer ElementHandles

I know it's a pain, but maybe we just have to write our own type inference or just add waitForOpts?: WaitForElementOptions as optional to the signature of all the methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could duplicate BoundFunctions but with ElementHandle instead of HTMLElement? Everything else should be the same I think


## Known Limitations

- `waitForElement` method is not exposed. Puppeteer has its own set of wait utilities that somewhat conflict with the style used in `@testing-library/dom`. See [#3](https://github.com/testing-library/pptr-testing-library/issues/3).
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure we want to remove this note, but maybe convert it to cover waitForDomChange and waitForElementToBeRemoved as well and nudge to "use the find* methods instead".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check latest commit, writing documentation is hard 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't use find* queries for waitForElementToBeRemoved, but I think we should be able to get that working nicely. Didn't get round to it in this PR but I'll raise an issue if anyone else wants to do it :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

sounds good thanks! :)

@umpox umpox changed the title Add findBy* queries Add find* queries Aug 18, 2020
@umpox umpox force-pushed the add-findby-queries branch from 4c0d3e9 to 4d96f87 Compare August 18, 2020 08:50
Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

thanks @umpox ! this is great stuff 👍

@weyert
Copy link

weyert commented Aug 18, 2020

Any plans to release a publish version?

jrolfs pushed a commit to testing-library/playwright-testing-library that referenced this pull request Aug 18, 2020
@umpox umpox deleted the add-findby-queries branch August 20, 2020 09:25
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.

Add findBy* async polling queries from @testing-library/dom add waitForElement support
3 participants