-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
to.have.attr passes when actual is undefined #11
Conversation
This certainly feels like unexpected results, both assertions actually pass: expect(undefined).to.have.attr('key', 'somekey');
expect(undefined).to.not.have.attr('key', 'somekey'); |
Yes this is a particulary nasty bug, I've found that I had a lot of cases passing even tho they should fail. |
At the very least, an enzyme expectation should always fail if the "actual" is not a non-array non-function object. |
Ok to summarise: the proposed fix will be to have all the chai-enzyme assertions throw an error if the "actual" is not a enzyme warpper |
yeah... that's a bit problematic. the thing is... we use to me this seems more or less like a chai.js issue, rather than chai-enzyme. @keithamus do you have any thoughts on this? |
/cc @logicalparadox |
Hey @vesln thanks for bringing me in on this. TL;DR: This will be "fixed" in version 4.0.0 of chai, but you shouldn't use overwriteMethod unless the method actually exists. (Which, I know, is a pain). This is kind of a chai bug, and kind of a bug with this lib. For context read chaijs/chai#467, but it boils down to:
So whats happening:
The "fix" for this is in Chai 4.x.x branch - it makes the default behaviour of |
@keithamus thanks a ton! in this case, @marcodejongh, i'd suggest to change the |
You can check to see if a method exists by looking at |
@@ -11,6 +11,16 @@ class Fixture extends React.Component { | |||
const it = createTest(<Fixture />) | |||
|
|||
describe('#attr', () => { | |||
it('fails when actual is not a enzymeWrapper', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('fails when the actual is not an enzyme wrapper'), () => {})
Looking good @marcodejongh 🙌, let's wait for @vesln and @andreasklinger to chime in before merging. |
to.have.attr passes when actual is undefined
The following assertion passes:
It also passes on
to.have.prop