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

matcher for is #97

Open
ljharb opened this issue Aug 16, 2016 · 5 comments
Open

matcher for is #97

ljharb opened this issue Aug 16, 2016 · 5 comments
Labels

Comments

@ljharb
Copy link
Member

ljharb commented Aug 16, 2016

I tried expect(foo).to.be.a('bar') to be a nicer form of expect(foo.is('bar')).to.equal(true), but it didn't work. What do you all think about a matcher for this?

@keithamus
Copy link
Contributor

👍 from me

@ayrton ayrton added the feature label Aug 29, 2016
@ahstro
Copy link

ahstro commented Oct 17, 2016

Shouldn't match do this? That is expect(foo).to.match('bar')?

@ljharb
Copy link
Member Author

ljharb commented Oct 17, 2016

"match" implies a selector/regex, and possibly multiple elements. is/be imply one exact identity.

@jeffcarbs
Copy link
Contributor

The .match() matcher seems to actually just be a wrapper around .is(). I just submitted a PR to make it more consistent and support any valid EnzymeSelector (see: #121).

Assuming that PR is merged, you'll be able to make assertions like:

expect(foo).to.match('div')
expect(foo).to.match('div.some-class')
expect(foo).to.match('MyComponent')
expect(foo).to.match(MyComponent)

That being said, I do agree that something like expect(foo).to.be.a(MyComponent) would be more clear. Perhaps they'd be open to a rename or you could alias is somehow in your codebase. Not too familiar with chai, tbh.

@ayrton
Copy link
Contributor

ayrton commented Nov 4, 2016

@ljharb - @ahstro is correct, the behaviour you want is currently what match does, that being said we could have done a better job at naming this and with @jcarbo's PR merged I think we should add support for .to.be.a 👯

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

No branches or pull requests

5 participants