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

Breaks Chai all.keys #24

Open
ThomWright opened this issue Dec 23, 2015 · 16 comments
Open

Breaks Chai all.keys #24

ThomWright opened this issue Dec 23, 2015 · 16 comments
Labels

Comments

@ThomWright
Copy link

Chai's built-in all.keys assertions seem to break when I use chai-things - Chai keys

expect({a: "string", b: "string", c: "string"}).to.have.all.keys(["a", "b"])

AssertionError: expected { Object (a, b, ...) } to have a property 'length'

@keithamus
Copy link
Member

Hey @ThomWright thanks for the issue.

This does seem to be a problem. I'd welcome a PR to fix this if you have the time 😄

@keithamus keithamus added the bug label Dec 23, 2015
@JohnBaileyN
Copy link

This is sad :(

@ThomWright
Copy link
Author

PR sent. The Travis build failed, but it seems to be because it hasn't been configured and is trying to build a Ruby project.

@jamespedid
Copy link

This might be a breaking change, but perhaps instead of using the word all, you use the word each.

expect(collection).to.each.have.property("foo", "bar")

instead of

expect(collection).to.each.have.property("foo", "bar")

This makes more sense grammatically as well.

@ThomWright
Copy link
Author

👍 That would probably be a better solution.

@lo1tuma
Copy link

lo1tuma commented Feb 10, 2016

I’ve exactly the same problem. The key/keys assertion isn’t usable at all if chai-things is used.

@wassname
Copy link

I agree that each is more intuitive than all, seems like a decent idea. You could even make it work for object values.

A workaround for this is omit writing "all", since chai defaults to using it anyway. From the chai docs:

Note, either any or all should be used in the assertion. If neither are used, the assertion is defaulted to all. [1]

@drzaal
Copy link

drzaal commented Apr 6, 2016

I tried to fix this. I might have gotten a bit overaggressive with it though.

Side effects include allowing testing over enumerable object properties
and the inclusion of synonym 'each'

#35

@wassname
Copy link

wassname commented Apr 6, 2016

Nice!

@drzaal
Copy link

drzaal commented Apr 6, 2016

Get unexcited. It's clear there are some implementation decisions in this module which are at odds with the chai implementations.

The 'contains' flag interaction is mandatory for 'any' and has no effect on 'all'

however in default chai the behavior is
'contains' has no effect on 'any', but determines whether 'all' is inclusive or comprehensive.

There is also a difference between the included chai package and most up to date package of chai.

@drzaal
Copy link

drzaal commented Apr 8, 2016

Okay. It's ready again. Whew.
#35

@poupryc
Copy link

poupryc commented Dec 28, 2017

I would like to ask for news of the issue ^^

@hypeofpipe
Copy link

Seems it doesn't work at all.

@master-of-null
Copy link

master-of-null commented Feb 20, 2020

It's pretty bad that this is 4+ years old. Just used chai-things and now have to revert. Didn't notice it wasn't maintained

@JonnoFTW
Copy link

If they aren't going to maintain this plugin it needs to be marked as archived and alternatives given for its use cases.

@JamieMcNaught
Copy link

Sadly the broken example of this still exists in the Chai documentation:
https://www.chaijs.com/api/bdd/#method_all

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