Skip to content

allow queryAllByText to select text nodes text content #209

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

Conversation

tylerthehaas
Copy link

closes issue #207

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Sweet 💯

@kentcdodds kentcdodds merged commit 677f4e9 into testing-library:master Feb 13, 2019
@kentcdodds
Copy link
Member

@all-contributors please add @tylerthehaas for code and tests

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @tylerthehaas! 🎉

@kentcdodds
Copy link
Member

🎉 This PR is included in version 3.16.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gnapse
Copy link
Member

gnapse commented Feb 13, 2019

After this was merged, I'm getting container.matches is not a function using cypress-testing-library. Any ideas why this could be?

Update: I can confirm it was this change. I edited my package json to force it to resolve dom-testing-library to v3.16.5 (the version prior to this being released) and my tests passed.

My cypress test's use of this library is a mere cy.getByLabelText('User name').type('john') (it's a new project and I'm just starting to write tests to it).

@kentcdodds
Copy link
Member

Hmmmm.. could you figure out what's going on? Maybe we need to just do a typeof check?

@gnapse
Copy link
Member

gnapse commented Feb 13, 2019

I'll try to carve out time to attempt to create a minimal reproduction repo, if no one has a brilliant idea before I can do that.

I initially suspected this element.matches thing was not supported by Cypress browser environment (as it happens, for instance, with EventTarget) but that seems unlikely, since that element method seems to have full support across all browsers.

@tylerthehaas
Copy link
Author

tylerthehaas commented Feb 13, 2019

The issue here is that cypress testing library is passing the document as the container. We should be able to do a check to make sure that container.matches is a function and that should solve this. I wont have time to implement this until after work tonight but will try to find time to do this if no one else gets to it before me.

@kentcdodds
Copy link
Member

Agreed 👍

@ruyaoyao
Copy link

TypeError: container.matches is not a function is happening to me too, while I was passing window.document to getByText in jest.

@valscion
Copy link
Contributor

valscion commented Feb 14, 2019

I've got a working fix for this, with a new test case that would fail. I'll create a PR shortly

EDIT: See #213 for a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants