Skip to content
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

Assertions on collections vs. single items #10

Open
jagregory opened this issue Sep 10, 2015 · 1 comment
Open

Assertions on collections vs. single items #10

jagregory opened this issue Sep 10, 2015 · 1 comment

Comments

@jagregory
Copy link

Hey, I'm liking the direction this library is heading. I think it has great potential to tidy up my React tests 👍

The only downside (and this is maybe rquery rather than chai-react, or something in between) the API is currently a bit awkward in places where it's unclear whether a method works against a collection or a single item.

For example:

const child = $node.find('.value')

expect(child).to.have.prop('id') // fails, need to use child[0]
expect(child.text()).to.equal('hi') // works, no child[0] needed

Coming from JQuery, all methods are available on the collection interface and just pass through to the first item if there is only one.

@percyhanna
Copy link
Owner

I assume you're referring to using rquery and chai-react together? I found myself wanting some better assertions myself while I was writing some tests today.

chai-react (or a new chai-rquery plugin) would need to have unique assertion names to avoid collision with other plugins like chai-jquery.

Definitely interested in exploring this in more depth.

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

No branches or pull requests

2 participants